01-03 Java keywords, identifiers, annotations, constants and binary questions, variables, and data types

Source: Internet
Author: User
Tags binary to decimal java keywords

1: Keywords
    (1) the words    (2) that are given a specific meaning by the Java languagefeature:        all lowercase.    (3) Precautions:        A:goto and const exist as reserved words.        B:advanced Notepad similar to Notepad + + has a special color tag for the keyword

2: identifier

    (1) is a sequence    of characters that give names to classes, interfaces, methods, variables, etc. (2) Composition rule:        A: English case letter        B: Digital        c:$ and _    (3) Note:        A: Cannot start with a number        B: cannot be a keyword in Java        C: Case Sensitive    (4) Common naming rules (see name)        A: The package    is actually a folder, used to distinguish the same class name  all lowercase            single-level packages: Lowercase                example: liuyi,com            Multi-level package: lowercase, and use. Separate                example: Cn.itcast,com.baidu                        B: Class or interface            one word: First capitalization                example: Student,demo            multiple words: Capitalize each word first letter                Example: Helloworld,studentname        C: Method or Variable            a word: First letter lowercase                example: name,main            multiple words: Starting with the second word, capitalize each word with an                example: Studentage,showallnames ()        D: Constant            all uppercase            one word: Uppercase                Example: PI            multiple words: Uppercase and separated by _                example: Student_max_age
3: Notes
    (1) The text that explains the program    (2) Category:        A: Single-line comment     //        B: Multiline comment/    * */        /**/
Note: Multiple lines cannot be nested, and a single row is OK
(3) wrote a annotated version of the HelloWorld case. We're going to write a procedure in the back. Requirements: Analysis: implementation: code embodiment: (4) The role of annotations A: Explain the program, improve the reading of the code. B: Can help us debug the program. later, we will explain a more advanced debugging tool

Example of writing a comment

/*Requirements: I am going to write a Java program, the "HelloWorld" This sentence output in the console analysis: A: To write a Java program, you must define class B: The data can be output, indicating that our program can be run independently, and the program to be alone Run, you must define the Main method C: Output The data in the console, you must use the OUTPUT statement implementation: A:java language provides a keyword: class is used to define classes, followed by the class name B:main method format is fixed : public static void Main (string[] args) {} C: The format of the output statement is fixed: System.ou            T.println ("HelloWorld"); "HelloWorld" is something that can be changed.*///This is my HelloWorld case.class HelloWorld {/*in order for the program to run independently, the main method is defined as the entry of the program is automatically called by the JVM*/Public StaticvoidMain (string[] args) {//in order to display the data in the console, we used the output statementSystem.out.println ("HelloWorld"); }}
4: constant
    (1In the course of program execution, the amount of its value does not change (2) Category: A: Literal constants B: Custom Constants (later) (3) literal constant A: string constant"Hello"B: Integer Constants12,23C: decimal constant12.345D: Character Constants' A ', ' a ', ' 0 'E: Boolean Constantstrue,falseF: Empty constantNULL( later) (4) provides four representations in Java for integer constants A: binary consists of 0, 1.        Start with 0b. B: Octal by 0,1,... 7 composition.        Start with 0 (0) . C: Decimal by 0,1,... 9 composition.        Integers are decimal by default. D: Hexadecimal by 0,1, ... 9,a,b,c,d,e,f (both uppercase and lowercase) are composed. Start with 0x.
/*constant: The amount at which the value does not change during program execution. Category: A: Literal constants B: Custom Constants (later) literal constants A: String constants are enclosed in double quotation marks.            Example: "Hello", "World", "HelloWorld" B: integer constant All integers example: 100,200 C: decimal constant all decimals    Example: 10.23,110.11 D: an example of a character constant quoted in single quotes : ' A ', ' a ', ' 0 ' ERROR: ' AB ' E: boolean constant More special examples: True,false F: null constants followed by example: null*/class Constantdemo {public staticvoidMain (string[] args) {//output of string constantsSystem.out.println ("Hello"); //output of integer constantsSYSTEM.OUT.PRINTLN (100); //output of decimal constantsSystem.out.println (100.10); //output of character constantsSystem.out.println (' a '); System.out.println (A); System.out.println (' 0 '); //This is problematic, character constants have single quotes, string constants with double quotes        //System.out.println (' ab ');                //output of Boolean constantsSystem.out.println (true); System.out.println (false); }}

5: Binary Conversion
    (1) Other decimal        coefficients: is the numeric cardinality of each bit: X-        cardinality is the X-        right: the data on each digit, from the right, and starting from 0, the corresponding number is the right of the data.                results: The sum of the coefficients * cardinality ^ power power.    (2) decimal to other binary in        addition to the base, until the quotient is 0, the remainder reversal.    (3) Fast conversion method        of the binary conversion A: The conversion between decimal and binary is            8421 yards.        B: Binary to octal, hexadecimal conversion

Binary overview and binary, octal, hex plots:

Different binary data performance:

 /*   Different binary data representation: binary: Consists of 0, 1.        Start with 0b. Octal: by 0,1,... 7 composition.        Start with 0. Decimal: By 0,1,... 9 composition.        The default integer is decimal. Hex: by 0,1,... 9,a,b,c,d,e,f (both uppercase and lowercase) are composed. Start with 0x.  */ class jinzhidemo {public static  Span style= "COLOR: #0000ff" >void   main (string[] args) {System.out.println (100); //  decimal   System.out.println (0b100);  //         binary  System.out.println (0100); //         octal  System.out.println (0x100); //  hex  }}  

Conversion of the binary

Other binary to Decimal

Decimal to other binary:

Fast Conversion Method:

Master Law

01-03 Java keywords, identifiers, annotations, constants and binary questions, variables, and data types

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.