First knowledge of Java

Source: Internet
Author: User

Java:

1, Boolean variable Boolean (BOOL)

2. Final float afinalvar=3.1415926 (#define AVar 3.1415926)

3, unary operator: prefix operator op;

Suffix op operator;

Binary operator: infix OP1 operator OP2

Ternary operator: OP1? OP2:OP3 equivalent to the If-else statement: If the OP1 is ture, return OP2, otherwise return OP3;

4. Output stream:

Java:System.out.println ("x=" +var); c:printf ("%s,str") c++:cout<< "x=" <<var<<endl;

5. Variable operation:

int + double is double;

6. For 10.0/0.0 (when both types are double) Java considers it to be legal and the result is infinity (Infinity) 0.0/0.0 result is undefined (NaN)

7, string and new string; int and new Integer; = = and equal ();

The string class is a constant of strings and is immutable. While StringBuffer is a string variable, its objects can be expanded and modified.

String.charat (int): Returns the first element of the string, but the stirng type has no subscript;

8. Array:

Statement:

Float[] Arryoffloat=new float[10] or float arrryoffloat[]=new float[10];

Int[] Anarry;

Anarry=new INT[10]; Gets the array length with length rather than length (). Here, length is the property that all arrays have, not methods.

Create and initialize:

Boolean[] answer={0,1,1,0};

String[] str={"You", "is", "abnormality"};

9. instanceof operator

OP1 (object name) instanceof OP2 (class name); Determine if OP1 is an object instance of OP2

10. Jump Statement

Break;continue;lable;return;

A), continue test;

b), break test;

First knowledge of Java

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.