Java learns from scratch (identifiers and keywords), starts from scratch andIdentifier, keyword, comment 1, identifier
The packages, classes, methods, parameters, and variable names in Java are composed of letters, numbers, underscores (_), and dollar signs ($) in any order,
Identifier: it cannot start with a number or be a reserved keyword in
Definition: A symbol that gives a name to a package, class, interface, method, variable, etc., consisting of letters, numbers, $, and _.
Hello he123$_ world$ good_ $hello _hello
The letters contain not only English letters, but also Chinese, French, German, Russian, and so on, Java supports the Unicode character set, contains various languages, and recommends the use of English letters.
hello123 Hello 123 привет123 ハロー123 olá123
Th
First, identifiersconcept: is used to give the program in the variables, classes, methods named symbols;identifier rules: Identifiers can consist of letters, numbers, underscores _, and dollar sign $, and numbers do not beginidentifiers cannot make Java keywords and reserved words, but can contain keywords and reserved wordsidentifiers cannot contain spacesidentifiers can only contain dollar sign $ and cann
the scanner object to scan the data. 3. Import the package. ImportJava.util.*; classDemo3 { Public Static voidMain (string[] args) {//Create a scannerScanner Scanner =NewScanner (system.in); //call scanner to scan keyboard input dataSystem.out.println ("Please enter a score:"); intScore = Scanner.nextint ();//defines a num variable to receive a scan to the content. } }
Array
classDemo4 { Public Static voidMain (string[] args) {//define an array int[] arr =New int[4];
Identifiers OverviewIs the sequence of characters used to name a class interface method variable, etc.Composition rulesEnglish uppercase and lowercase lettersnumeric characters$ and _PrecautionsCannot start with a numberCannot be a keyword in JavaCase-sensitive, which means that large lowercase points to different objects, similar to JavaScript and Pythonidentifier ExampleA valid identifierHelloworld_123__DemoBj_$22An illegal identifier.Hello World ca
Package name All letters are lowercase, for example: Com.qiuyin.test.
The class name and interface name are capitalized on the first letter of each word, for example: UserName, Iterator.
Constant names All letters are capitalized, and the words are underlined, for example: Day_of_month.
The first letter of the variable name and method name is lowercase, starting with the first letter of each word from the second word, for example: LineNumber, Getlinenumber
program, try to use meaning
-0=256Byte ..... (byte) 300; 44 300-44=256Equivalent to the data with strong turn-256;Range of Byte: 128 ~ 127128:10 million-128:10000000 (1 Here is the sign bit, also the value bit)3: Default conversion of data type conversionsByte,short,char--INT--long--float--doubleLong:8 bytesFloat:4 bytesA: Their underlying storage structure is different.The range of data represented by B:float is larger than the range of longLong:2^63-1float:3.4*10^38 > 2*10^38 > 2*8^38 = 2*2^3^38 = 2*2^114 > 2^63-14:
[Original reprint annotated Source]Comments:Single-line Comment://Multiline Comment:/* */Document Comment:/** */Where document comments can export dox documents, common Javadox tags are as follows:@author: Specify the author of the Java program@version: Specify the version of the source file@deprecated: Deprecated Code@param: Parameter description information for a method@return: The return value description information for the method@see: "See" for s
make their votes invalid4. XOR: There is only one person who can vote to approve the issue.
Short Circuit phenomenonFor example: (One > both) (one Similarly, in (One > both) | | (One
Conditional operators
The conditional operator (? :) also known as the ternary operator.Syntax form: boolean expression? Expression 1: Expression 2String mark = (>60)? "Pass": "Fail";Operation procedure: Returns the value of expression 1 if the value of the Boolean expression is true, otherwise
Identifiers are names that give classes, interfaces, methods, and variables, and represent references to memory space.
Identifiers consist of numbers, letters, _, $, but cannot begin with a number. Because Java is encoded in Unicode, it contains the alphabet (including Chinese) for most countries.
Naming conventions:
Project name, class name: First letter capi
Identifier:Start with a letter, underscore (_), dollar sign ($)You cannot use keywordsCase sensitiveYou can divide int a = 1_0000_0000_1121 with an underscore;Data type:int defaults to decimal, octal starts with 0, Hex starts with 0xSYSTEM.OUT.PRINTLN (*) Default output decimal* at Integer.tobinarystring ()-and binary; octal (octal); Hex (hex)If the size of the data does not exceed Byte/char/short's stated range, it can be automatically transformed ☆1Long int constant at the end plus LFloating p
com.apple.quicktime.v2 Edu.cmu.cs.bovik.cheese, etc.;interfaces: naming rules: Casing rules are similar to class names. For example:interface rasterdelegate;method: The method name is a verb, in the form of a mixed case, the first letter is lowercase and the first letter of the word is capitalized. For example:run (); Runfast ();variables: except for variable names, all instances, including classes, class constants, are mixed in case, the first letter is lowercase, and then the first letter of
("My_var")); *System.out.println ("$my _var is an identifier?" +javaidentifier.isjavaidentifier ("$my _var")); $System.out.println ("My_var.1 is an identifier?") +javaidentifier.isjavaidentifier ("My_var.1"));Panax NotoginsengSystem.out.println ("1$my_var is an identifier?") +javaidentifier.isjavaidentifier ("1$my_var")); -System.out.println ("U0391var is an identifier?") +javaidentifier.isjavaidentifier ("U0391var")); theSYSTEM.OUT.PRINTLN ("Null is an identifier?") +javaidentifier.isjavaident
Key wordsDefinition: A string ( word) that is given special meaning by the Java language and used as a specialized purposeFeature: All characters in the keyword are lowercaseIdentifiersName (variable, method, Class)Naming rulesComposed of 0-9, 26 English-case and _ or $Numbers can not startYou cannot use keywords and reserved words.Strict case sensitivity in Java Variables (basic data types, basic data type
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.