Java Basic Syntax Tip summary: (one quiz)

Source: Internet
Author: User

1. The rules for Java identifiers are like this

Identifiers consist of letters, numbers, underscores "_", dollar Sign "$" or the renminbi symbol "¥", and the first letter cannot be a number. That is, in addition to _ $¥ these 3 symbols, identifiers can only have numbers and letters, what parentheses, so that is not part of the identifier.

You cannot use keywords and reserved words as identifiers.
Identifiers do not have a length limit.

String $;
String Y2;
String idfkd$fff;
String ADKYDKJK;
String _DJFKDJ;
String dkjfkdj_dfe;
String f444d;

2. When you define an array in Java, you cannot specify both length and initialization.

string[] STRs = new string[3]{"abc", "Dee", "FFF"}//This is wrong

3, Java = = logical expression on both sides of the type must be convertible to the same type of variable, that can be automatically type promotion (conversion), or compile error

int i = 3;

String str = "3";

if (i = = str)//This sentence will be error when compiling

{......}

4, in Java, the byte variable can be assigned a value of 0-255, more than 255 must use coercion type conversion, or compile error

For example: byte = 120; That's right

byte = 300; This is wrong.

5. The average array is printed by SYSTEM.OUT.PRINTLN () as the memory address value and the group type. With the exception of the character array, it prints the result of the string itself.

For example: char[] CHS ={' A ', ' B ', ' C '};

System.out.println (CHS);//print Result: ABC

int[] numbers = new int[]{2,3,4,5};

SYSTEM.OUT.PRINTLN (numbers); Print result: [[email protected]

Java Basic Syntax Tip summary: (one quiz)

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.