Chapter 3
Identifier, keyword, Data Type
Comments/single-line comments/* multi-line comments * // ** docized processing **/
Javadoc source. Java Automatic Document Generation Tool
Variable
The variable data executed in the program becomes the variable name and variable value.
Java case sensitive
Variables must be defined before use
The names of various variable methods and classes in Java are called Identifiers (that is, names)
Words in Java that are given specific meanings and used for special purposes become keywords.
All Java keywords are in lowercase.
Data Type
Basic Data Type
Numeric Integer type byte short int long floating point float double
Character char
Boolean
Reference data type class interface Array
Jav, four types, eight basic data types, logical type, Boolean numeric type, char Integer type, byte short int long floating point type, float Double Type
The boolean type is suitable for logical operations. Generally, it is used for flow control and can only be true or false.
Cannot be 0 or not 0
Char indicates the character char c = 'a '; A character constant is a single character enclosed in single quotes. It can also be converted to another meaning by using the Escape Character "/". Char c = '/N' indicates a linefeed.
Add l long I = 3l when declaring a long integer;
Double D = 3.14;
Float F = 3.14f; float needs to be added with F double to indicate that the range is large.
{
Char c = '/N ';
System. Out. Print ("AA ");
System. Out. Print (c); // reference C for line feed
System. Out. println ("AA ");
}
Data types other than the eight basic types are referred to as reference types.
Reference type data exists as objects
The value of the referenced type variable is the handle of an object, not the object itself.
Declaring referenced variables is not instantiated
Unreferenced type variables are allocated and instantiated.
Boolean initialization value: false
The default value of all reference types is null.
String is the most common Java reference type.
String Class Object saves unchangeable UNICODE character sequences
String S = "Hello World ";
String-type data can be connected to any other data type by performing a + operation.
The reference type data passes the reference to the object (the reference to the address, and the data points to it) when the object itself is relatively basic type, its data exists in the stack memory, the reference type address also exists in the stack memory, and the object of the reference type instance exists in the heap memory.
This is to solve variable naming conflicts and uncertainties.
The constructor specifies the new object created by this method.
The object that calls this method in a common method.
Naming Convention
Package name
Class Name
Interface
Method Name ()
Variable name
Constant name head_count maxihum_size