"Java" Learning Notes (1)

Source: Internet
Author: User

Java data type:

Base data type: (variable in stack) numeric: byte ( 1 short ( 2 bytes)   int (four bytes)   long ( 8 float ( 4 bytes)   double ( 8 bytes)

Character type:char(2 bytes)

Boolean type:boolean

Reference data type (variable reference in the heap): Class interface array

Cannot replace true or false with 0 or not 0

Java uses 8 bytes to represent a long with 2 bytes for a char, and the characters to use Unicode encoding can also ' \u+16 ' denotes a character.

8 binary number with 0 beginning hexadecimal number starting with 0x binary number with 0b

There is no unsigned number in Java, you can use a long type to handle four-byte unsigned numbers

The default shape is int If you use long after +l

Floating-point thousands of points can be underlined: 123_456.789_000 = = 123456.789

Float type defaults to double , to represent floating-point numbers after +f

Identifiers: Can be combined with alphanumeric _ $ to begin with cannot be a number

Java is case sensitive, the class name is capitalized with the rest of the first letter lowercase, constants are defined with use

Arithmetic operators:15/4(z integer division) 15.0/2(real division)

Java logical operators:&&(short circuit and) | | (short circuit or)

Bitwise operations:>>>(unsigned number right shift) highest bit 0(normal right shift >>highest bit complement original sign bit int is to + bit taking mode Long is to - bit-taking mode)

String Connector +

The declaration method of an array int []a = new int[3];

the Java array is a reference type, and once the space is allocated, each element is implicitly initialized, the value type is 0, and the reference type is NULL .

The properties of an array can be specified in length by . length .

The enhanced for statement makes it easy to access the elements in it:

int []ages = new int [10];

for (int age:ages)

{

System.out.plintln (age);

}// read-only traversal

Methods for copying arrays:

Example of copying a source.length element starting from subscript 0 to the destination array in the source array (sources) from subscript 0 location to begin storage.

Array.copy (Source,0,dest,0,source. Length);

Declaration methods for two-dimensional arrays:

int [][]t = new int [3][];

T[0] = new int [2]

T[1] = ...

T[2] = ...

Multidimensional arrays should be declared in order from high to low dimensions, unlike C + + .

"Java" Learning Notes (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.