System.out.print () Last output no carriage return
System.out.println () The last output has a carriage return
System.out.print ()
The output format is splicing type
such as output 1+2=3
System.out.print (1+ "+" +2+ "=" +3);
Three types of formal parameters
Int,double/float,boolean
Array definition
Int[] A = new int[5]
Int[] A = new int[]{1,2,3,4}
The length of the array a.length
A is present in the stack, the array is stored in the heap, and a gets the 0-bit address value in the array
(Local variables are present in the stack, global variables exist in the heap)
The heap opens up space, can be saved, the stack is run once and disappears
But when the entire file is executed, the memory of the array's heap is freed
Java is better than C + + for memory optimizations, Java has a garbage collection mechanism, and C + + requires programmers to do it manually
If I now define a = = null (lowercase) then nothing points to the array, and the garbage collection mechanism frees the space at an irregular time.
1. So if I now define a int[] b = A;a = = NULL
Output B[1] Results returned 2
2. Definition int[]b = A; A[1] = 5;
Output B[1] Results returned 5
Because A or B is obtained is the address of the array's 0-bit, if change the current a[1] then the equivalent at this address changed the value
Unlike defining int b = a[1], changing the value of a[1],b again does not change
About classes
Class is equivalent to a separate function
Sample Example
Class car{ String color = "Red"; static int num = 4; public static int run () { //System.out.print (num); return num; }} Class test{public static void Main (string[] args) { car c = new Car (); C.color = "Blue"; System.out.print (C.run ());} }
In this case, static meaning is the equivalent of opening a space, and here the int is a local variable, only exists in the stack, can not be conducted
Learn Java DAY3 from scratch