An array of Java Basics Review notes series
1, the initial introduction of the array?
Arrays in Java are reference types and cannot be allocated directly on the stack. Unlike C (in Java, all types are reference types except for the underlying data types.) )
When an array in Java is declared, it cannot specify its length. differs from C
The array's decimal mark can be an integer constant or an integer expression.
The. Length method is the length of the display array; String.Length (); One is a property and one is a method. Note the distinction.
2. Memory analysis of arrays?
Array a[];
A = new Integer (15);
/* This A is in the stack, new in the heap 15 basic data types, a is stored in the address. The heap contains 15 values that are initialized to null.
Array a[];
A = new date[12];
/* Same as a in the stack, new 12 references are made to the heap, each of which points to a date, which is initialized to null by default before it is pointed.
3. Initialization of arrays: static initialization and dynamic initialization?
Dynamic initialization, allocating space first, then assigning values. Int[] A = new int[]; it is wrong to: int[] A = new int[23]; Be sure to allocate space.
Static initialization, when the array is defined, allocates space and assigns values.
4, public static void main (string[] args) How to understand?
String[] args, after all, is just an array. We can print it out. System.exit (-1); Indicates the system exits. -1 indicates an abnormal exit. 0 indicates normal exit.
The problem is that the type of the string is entered. How do we convert string types to some of the basic data types we use? Wraps the data of the underlying type into an object. (think clearly, the object is placed on the heap.) The basic data types are basically on the stack). Packaging categories are: Character,byte,boolean,integer,float,double and so on.
System error, generally can be used in this way: System.out.print ("system error"); System.exit (-1);
5, the ranking algorithm is most incomparable, then sort how to row it?
6, trinocular operator?
Return year > Date.year? 1
: Year < date.year? -1
: Month > Date.month? 1
: Month < Date.month? -1
:d ay > Date.day? 1
:d ay < date.day? -1:0;
7, array as the return value of understanding?
The return is also an array of references to this reference in the stack space. This application of the stack space points to an array in the heap. Returns an array whose essence is to return a reference.
8, programming small exercise: ring hand in hand, number 3 exit, the last remaining is who? Number 3 back
Stay in the code analysis.
9.
Java Basics Review Notes series four