-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReferenceCode.java
56 lines (40 loc) · 1.22 KB
/
ReferenceCode.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
public class HelloWorld
{
public static void main(String []args)
{
String myStr = "abc", myStr3;
myMethod(myStr);
System.out.println("myStr=" + myStr);
StringBuffer mySB = new StringBuffer("abc");
myMethod1(mySB);
System.out.println("mySB=" + mySB);
myMethod2(mySB);
System.out.println("mySB=" + mySB);
myStr = "abc";
myStr3 = myMethod3(myStr);
// \n in a println string moves to a new line.
System.out.println("\nmyStr=" + myStr);
System.out.println("myStr3=" + myStr3);
}
public static void myMethod( String str )
{
str = str + "xyz";
System.out.println("\n str=" + str);
}
public static void myMethod1( StringBuffer sb )
{
sb.append( "xyz" );
System.out.println("\n sb=" + sb);
}
public static void myMethod2( StringBuffer sb )
{
sb = new StringBuffer( "123");
sb.append("456");
System.out.println("\n sb=" + sb);
}
public static String myMethod3( String str )
{
str = str + "xyz";
return str;
}
}