Basic requirements for writing Java programs
1. Writing Java classes is actually writing Java files ( By default, the class name and file name require the same )
2. When writing a class, it should be placed in a package
meaning of the package : display of a folder ( reflection of the hierarchical relationship of a document )
The hierarchy in the package depends. Layer in to differentiate between different Java files
The application between packages
1. Create the class package name (indicating the location of the class)
2. Use the class import package name. class name (can use * to represent all)
Basic data type:
1. Identifiers
Named rules:
1. Letters, underscores, numbers, $, composition, but numbers cannot be started
2. Case sensitive
3. Cannot use keywords
4. Habits
1. Requires a certain semantics, all the letters lowercase
2. The first letter of the class name is capitalized student, and the first letter of the variable name is lowercase studentname
3. Connect File_path between words
2. Basic data type (8 types)
1. Integral type
|
Byte |
1 b 8 bit |
-128--127 |
|
|
|
|
short |
2b 16 |
-2^15 |
  |
Span style= "font-size:18px" >  |
  |
|
int |
4 32 |
-2^31 |
  |
|
  |
|
Long |
8 64 |
-2^63 |
|
|
|
2. Floating point
|
Float |
4 B 32 |
|
Double |
8B 64 |
3. Characters
|
Char |
2 16 |
|
|
4. Boolean |
|
|
|
Boolean |
1 b True/false |
|
Conversions between types
1. The positive
Byte-short (char)-int-long-float-double
2. Reverse (forced conversion)
(conversion type) identifier/number
Features of Java
Reference data type
Class, interface, array
Reference type identifier (variable) = new reference type (parameter)/[parameter]: constructor of reference type
String S=new string ("");
Int arr[] =new int[10]
Difference between reference type and base type ( memory )
Stack memory: Storing simple data types (variable names and values)
Heap memory: Used in conjunction with stack memory, where the first address of the heap memory is stored, and the referenced instance is stored in the heap (the portal/attribute of the definition of the method)
Basic statement:
Operator
Shift Operators
>> All symbols Right shift
>>> right-shift high-fill 0
logical operators
&/|
&&/| |
!
Arithmetic operations
+ + use: do not use i+=1;
Declaration of a process statement variable
Global variables: Scope is the entire file
Local variables: part of the method
Use of Operators
Order
Branch if: else/
Switch (Byte/short/int/char)
...
Cyclic for/while
***********************************************************************************************************
Reference type
Array: is an object
Declaring an array
type [] array; Recommended /Type array[]
Create an array
Space in the heap memory, specifying the length of the array, length once specified cannot be changed
Multidimensional arrays
Type []: array//Declaration and creation
Properties and methods of arrays
Arrays are provided by JAVAAPI, with certain methods and properties
Regain Java Memoirs (i): JAVA01 basic data types and basic statements