(1) Interview questions:
There is no length () in the array, there is no length () in the string, is there a length () in the collection?
数组中没有length()方法,只有length属性 字符串中有length()
(2) Interview questions:
string S1 = new String ("abc");
String S1 = "abc";
How many objects are created by these two separately?
= =: The address value is compared
equals: The default comparison is the address value, the string bottom overrides the Equals method, and all the comparisons are the same
(3) Interview questions:
What is the difference between StringBuffer and string?
The former is a variable sequence of characters, which is an immutable sequence of characters
When a string is defined in terms of memory, it opens up space in a constant pool, which is more memory-intensive
and StringBuffer, the string buffers (all of which are stored in strings), will be freed
(4) Interview questions:
What is the difference between a stringbuffer and an array?
Array: It is a container that can store multiple data, and the type of multiple data must be consistent
Array length function: Length Property
StringBuffer: It is a container, which is always stored in a buffer with only string types of data
Gets the length of the buffer: length ()
Java face question (v)