A review of Java Fundamentals: Key words, identifiers, annotations, constants, conversions, variables, data types, data type conversions

Source: Internet
Author: User
Tags binary to decimal

1. Key words

1.1. Words that are given meaning by the Java language (e.g. class,interface,public, static)

1.2. All lowercase

1.3. Precautions (Goto and const are reserved as key words)

2. Identifiers

2.1, to the class, interface, method, the character of the name of the variable

2.2. Composition rules (A: English case, B: Data, c:$ _)

2.3. Precautions (cannot start with a number, cannot be a key word in Java, case-sensitive)

2.4. Common naming rules (see name)

A: The package is all lowercase

Single-level package: lowercase such as: peng,com

Multi-level package: lowercase such as: Cn.hcc,ts.hnyj,com.baidu

B: Class and interface:

A single language: Capitalize the first word such as hello,student

Multiple words: Capitalize the first word of each word, such as Helloworld,studentname

C: Methods and Variables:

One word: First letter lowercase such as Name,main,get

Multiple words: First letter lowercase, starting with the second word capitalize the first word such as Showallstudents,getpersonname,classname

D: constant: All caps

One word: all uppercase

Multiple words: Multiple capitals while each word is separated by _ such as Max_age

3. Constants

3.1 The amount of the value does not change during program execution

3.2 Categories:

3.2.1, string constant "Hello",

3.2.2, Integer constant 12, 23,

3.2.3, decimal constant 12.33,

3.2.4, Boolean constant True,false

3.2.5, character constant ' a ', ' B '

3.2.6, empty constants

3.3 provides four representations of integer constants in Java

A: Binary consists of 0, 1, starting with 0b

B: octal is composed of 0---7, starting with 0

C: Decimal with 0----9, integer by default is decimal

D: Hex with 0----abcdef (case can) start with 0x

4, the conversion between the binary

The other ways to convert the binary to decimal are:

       1112              =         1*10^3  +  1*10^2  +  1*10^1+2*10^0       =            1000+100+10+2       =                    1112

0b00001010 = 1*2^3 + 1*2^0 = 8 + 2 = 10

----to Be Continued

A review of Java Fundamentals: Key words, identifiers, annotations, constants, conversions, variables, data types, data type conversions

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.