Copy the java 9th notes, compare strings, arrays

String comparison: Comparison ascll code
"abc" .compareto ( "bcd" ) // - 1: // "abc" than "bcd" small
"abc" .compareto ( "abc" ) // -; equal equals ( ) ture
"ABC" .compareto ( "AAA"). 1 //
ratios are equal
"abc" .equals ( "abc" ) ture

Stack:
1) Small storage space
2) and high deposit efficiency taken

Stack
1) storage space
2) automatic initialization data

Copy the array
int [] nums = {1,2,3,4,5};
// declare arrays
int [] nums = {97, 122, 85, 40, 62 is};
// get a desired array element and nums the same, but this does not change the array nums impact
@ 2.1 native code
// build a new array
int [] = num2 new new int [nums.length];
3. assignment //
for (int I = 0; I <nums.length; I ++) {
[I] = the nums [I] num2;
}
. 1) of the method of their data API =
// int [] = num2 nums.clone (); shallow clone // array (deep clone Sharp clone VS)
2) a method Arrarys / Arrays of copyOf method: in addition to position an exact duplicate can increase (expansion) minus position (reduced)
int [] = num2 Arrays.copyOf (the nums, nums.length);

Published 12 original articles · won praise 0 · Views 26

Guess you like

Origin blog.csdn.net/qq_45212924/article/details/104603751