Java face question (v)

Source: Internet
Author: User
(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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.