Use idea to try to write Java code today, the interface is really good, but to adapt to the new IDE
1.utf-8 is an international universal code, its English account for one byte, Chinese accounts for three bytes, and GBK is a domestic encoding format, of which both Chinese and English accounted for two bytes
2. Creation of arrays
A. Array if only the length of the array is declared, the initial value of the data type is shown
byte[] ByteArray =New byte[1]; Char[] Chararray =New Char[1]; int[] Intarray =New int[1]; Long[] Longarray =New Long[1]; float[] Floatarray =New float[1]; Double[] Doublearray =New Double[1]; String[] Stringarray=NewString[1]; //Initial valueSystem.out.println ("Byte default type is:" + bytearray[0]);//0SYSTEM.OUT.PRINTLN ("Char default type is:" + chararray[0]);//SYSTEM.OUT.PRINTLN ("int default type is:" + intarray[0]);//0SYSTEM.OUT.PRINTLN ("Long Default type:" + longarray[0]);//0System.out.println ("Float default type:" + floatarray[0]);//0.0System.out.println ("String default type is:" + stringarray[0]);//NULL
B. Two ways to create an array
int New int [2]; a1[0] = 1; a1[1] = 2; int [] A2 = {10, 22, 3, 4, 52};
Or recommend the second kind
C. About foreach
The Java foreach is in the form of a for (data type variable name: array name), and if it is not traversed with an array's index, the data type of the variable should be consistent with the array, as shown in
Public classVerify { Public Static voidMain (string[] args) {//single data type array traversal output float[] A1 = {1.2f, 2.3f, 4.4f, 7.6f, 9.1f}; for(floatfl:a1) {System.out.print (fl+ " "); } System.out.println ("\ n"); //array of type stringstring[] A2 = {"1", "2.3", "Nihao", "a"}; for(String str1:a2) {System.out.print (str1+ " "); } System.out.println ("\ n"); //iterating over an array with an array's index Double[] a3 = {1.2, 2.2, 3.1, 4.5, 5.3}; for(inti = 0; i < a3.length; i++) {System.out.print (A3[i]+ " "); } }}
D. Copying of arrays
Focus on understanding the relationship between copied and replicated arrays
Public classpracarraycopy { Public Static voidMain (string[] args) {int[] a1={1,2,3}; int[] a2={4,5,6}; /*directly with "=" You can overwrite the array data after the change A1 and A2 point to the same array and any array to modify the array data, the other elements of the array will change*/A1=A2; for(intx:a1) {System.out.println (x); } a1[0]=100; a1[2]=66; for(intx:a2) {System.out.println (x); } }}
Today, I accidentally found out that the IDE tool, the interface is much better than eclipse, but the first hand, slightly rusty, later enhanced use. Two days after the Ming Dynasty, it is really great welfare ah, it seems that after a double Hugh work to go, haha, bath sleep
2016.10.21 to Bide