The identifier in Java can be a $ character, and the default is that int type exceeds int must be indicated by a long type
Char is 2 bytes
String is a reference type
byte B = 1;
B = B + 1; #会报错, type mismatch, B promoted to int, cannot be assigned to byte, requires strong turn
B + = 1; # yes, equivalent to B = (byte) (b + 1)
#################### day03 #############################
Import Java.util. Scanner
Scanner sc = new Scanner (system.in); Reading keyboard
int val = Sc.nextint (); Accept int only, others will error
string s = Sc.next ()//read string
Random class
Import Java.util.Random
Random rand = new Random ();
int i = Rand.nextint (100); Generates an integer between 0-99
Double d = rand.nextdouble (); Generates a random number between 0.0 and 1.0
For and if break continue with C + +
############## #day04 #############################
Data types accepted by the switch expression
JDK 1.0-1.4 byte short int char
JDK 1.5 byte short int char enum
JDK 1.7 byte short int char enum String
Case penetrating
Array definition differs from C for reference type
int [] arr = new int[3];
Arr saves the addresses in the heap
Arr.length array Size
int[] arr2 = new int[]{1,2,3,4} # int cannot write any length, otherwise compilation fails
int [] ARR3 = {1,2,3,4}//recommand
Two-dimensional array lengths in Java can be unequal
int[][] arr2d = int new[3][4]
int[][] arr2d = {{}, {4,5}, {6}}
################## day05 ################
Method methods
Overload overloads, same as c, see only method names and parameter lists
################# day06 ###############
Classes in Java are reference types
Phone p = new phone ();
P is an address that allocates space in the heap, equivalent to C + + allocated in the heap
Assigns a default value to a Class's properties when allocating space
Import Java.util. ArrayList
must indicate type
arraylist<integer> arrlist = new Arraylist<integer> ();
The collection is stored in a reference type and does not store the base type
# method
1 Arrlist.add ()
2 Arrlist.get (index) starting from 0
3 Arrlist.size ()
4 Arrlist.add (index, data) Insert to index position
5 Arrlist.set (index, Data) Modify the index value to data
6 Arrlist.remove (index)
7 Arrlist.clear ()
######################### day07 ############################
A 97
converting between char int and C + +, querying ASCII
Char is stored in Chinese when querying a Unicode table, Kanji 2 bytes
Value range 0 ~ 65535
Select sort, Bubble sort, Array reverse order
Java Learning Diary (1-7)