1.Java When creating an array, it is divided into two types, one static creation and one for dynamic creation.
(1) statically created as string[] array = {"A", "B", "C"}; (2) dynamically created as string[] array = new string[] {"A", "B", "C"}; or string[] array = new STR ING[3];(First confirm the number of elements) in general the use of dynamic creation method is more flexible, you can first specify the number of elements after each element is assigned value.
- int a [+] , corrected to int a[]; an array of indeterminate lengths or to an int a[] = new int [+]
The difference between 2.equal and = =:
String S1 = "abc"; String s2 = "abc", if (s1.equals (S2)) {System.out.println (true);} else {System.out.println (false);}
Replace with <span style= "White-space:pre" ></span> if (s1== (S2)) {<span style= "White-space:pre" > </span>system.out.println (true); <span style= "White-space:pre" ></SPAN>} else {<span style= " White-space:pre "></span>system.out.println (false); <span style=" White-space:pre "></SPAN>}
<pre id= "best-content-1858690082" accuse= "acontent" class= "Best-text mb-10" style= "margin-top:0px; margin-bottom:10px; padding:0px; Font-family:arial, ' Courier New ', Courier, song body, monospace; White-space:pre-wrap; Word-wrap:break-word; Color:rgb (51, 51, 51); font-size:14px; line-height:24px; Background-color:rgb (241, 254, 221); " The data types in >java can be divided into two categories: 1. The basic data type, also known as the original data type. Byte,short,char,int,long,float,double,boolean the comparison between them, apply the double equals sign (= =), compare their values. 2. Composite data type (Class) when they compare with (= =), they compare the storage address in memory, so unless it is the same new object, their comparison result is true, otherwise the result is false. All classes in Java are inherited from the base class of object, and a method of equals is defined in the base class in object, and the initial behavior of this method is to compare the memory address of the object, but in some class libraries This method is overwritten, such as String,integer, In these classes, date equals has its own implementation, rather than the comparison class's storage address in heap memory. for the equals comparison between composite data types, the comparison between them is based on the address value of the location in memory where the Equals method is not covered, because the Equals method of object is compared with the double equals sign (= =). So the result of the comparison is the same as the double equals sign (= =).
Summary: Simple data internal equal and = = are the size of the comparison values
Complex data Type = = compares the storage address of the memory
Java Interview Trap review