Interview Question one:
The difference between String,stringbuffer,stringbuilder?
* A:string content is immutable, and stringbuffer,stringbuilder is content-changeable.
* B:stringbuffer is synchronous, data security, low efficiency; StringBuilder is out of sync, data is unsafe, high efficiency
Interview question two:
What is the difference between stringbuffer and arrays? And it is the most commonly used, functionally and stringbuffer exactly the same
* Both can be seen as a container for other data.
* But, StringBuffer's data is ultimately a string of data.
* While arrays can place a variety of data, but they must be different arrays of the same data type have different data types.
Interview question three:
Does the string type of data pass as a formal parameter change the actual parameters?
Through code Validation:
public Class Stringbufferdemo {public static void main (string[] args) {String S1 = "Hello"; String s2 = "World"; SYSTEM.OUT.PRINTLN (S1 + "---" + s2);//Hello---worldchange (s1, S2); SYSTEM.OUT.PRINTLN (S1 + "---" + s2);//Hello---worldstringbuffer sb1 = new StringBuffer ("Hello"); StringBuffer SB2 = new StringBuffer ("World"); System.out.println (SB1 + "---" + sb2);//Hello---worldchange (sb1, SB2); System.out.println (SB1 + "---" + sb2);//Hello---worldworld,}//method overload public static void Change (StringBuffer sb1, Stri Ngbuffer sb2) {sb1 = Sb2;//sb1=world, there is no change to the original SB1. Sb2.append (SB1);//append stitching mode. }public static void Change (string s1, string s2) {S1 = S2;s2 = s1 + s2;}}
</pre><pre code_snippet_id= "1677075" snippet_file_name= "blog_20160510_3_2822793" name= "code" class= "Java" > Conclusion:
<pre name= "code" class= "Java" >/* string passed as parameter * StringBuffer passed as parameter * * formal parameter: * Basic type: Change of formal parameter does not affect actual parameters * Reference type: Changes in formal parameters directly affect actual parameters * * Note:
*<span style= "White-space:pre" ></span> Special case: * String reference type is passed as a parameter, and the effect and base type are passed as arguments. That is: changes in formal parameters affect actual parameter changes.
The next article begins to enter the arrays class.
The first season of Java