Java data types and operations

Source: Internet
Author: User
Tags array length

(i), Java Basic types and operations

Note: can be used to generate APIs;

Commands such as: javadoc-d apidoc windowtitle hhh-doctitle aaa-header bbbb-version-author *helloworld.java

   Note the point:

1, identifiers can only be letters, numbers, underscores, and $, where numbers cannot begin with

2, base type: 1 bytes corresponds to the computer's 8-bit binary, the computer accesses the integer in the form of a complement, that is, the complement of the positive number is its own, and the complement of the negative is its inverse code (at the highest level, the rest is reversed) and then add a

3, type changer: small type for large type is implicitly loaded for example: float a=1, (non-secure), but like string type reload (show conversion: safe) and large type of small type (need strong turn)

4, character operations: such as: ("a" +7+ "he") and (' A ' +7+ "he") is not the same as the latter is 104he because Byte,short,char and integers add the largest range of values (that is, int)

5, the stored position of the character is a constant pool, such as String s= "a" string s2= "a" s==s2 (because S and S2 both point to the location where the constant pool of "a" is stored)

6, shift operation: For the negative number is in the complement of the computer, so the shift calculation in its complement, and then return its decimal value such as -5<<2=-20 (the left shift is equal to and multiplied by the POW (2, moving the number of bits), with the symbol right shift is equivalent to the addition of the operation (down (small) results such as the value is ,-1], the result is-2, and the value is located at [+] results of 1)

7, logic operation: short-circuit with &&     Non-shorted and &, non-shorted or | Precedence of operator: descending from top down

      

(ii) Control structures and arrays

1, use if else if () must first deal with a small range of

2, switch (expression) {case Code slice: break;...default:} Where expression can be a byte,short,int,long,char,string and enum (enum) type

3,break: End a loop continue: End a loop return: End method (no matter how many layers of loops)

Array

1, array declaration of two ways: type arrayname[]; Type[] arrayname; (recommended) array length cannot be declared when an array is defined

2, Array initialization: Arryname=new type[]{element1,...}; or arrayname=new Type[num];

3, Memory Distribution: array references (array names) exist in stack memory, and array objects exist in heap memory through array references to access the data in the array object. (The same is true for two-dimensional arrays)

Java data types and operations

Related Article

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.