-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringBufferObjectsAsParameters.java
More file actions
39 lines (31 loc) · 1.73 KB
/
Copy pathStringBufferObjectsAsParameters.java
File metadata and controls
39 lines (31 loc) · 1.73 KB
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
// This program illustrates how StringBuffer objects as
// parameters work.
public class StringBufferObjectsAsParameters //Line 1
{ //Line 2
public static void main(String[] args) //Line 3
{ //Line 4
StringBuffer str = new StringBuffer("Hello"); //Line 5
System.out.println("Line 6: str before "
+ "calling the method "
+ "stringBufferParameter: "
+ str); //Line 6
stringBufferParameter(str); //Line 7
System.out.println("Line 8: str after "
+ "calling the method "
+ "stringBufferParameter: "
+ str); //Line 8
} //end main //Line 9
public static void stringBufferParameter
(StringBuffer pStr) //Line 10
{ //Line 11
System.out.println("Line 12: In the method "
+ "stringBufferParameter "); //Line 12
System.out.println("Line 13: pStr before "
+ "changing its value: "
+ pStr); //Line 13
pStr.append(" There"); //Line 14
System.out.println("Line 15: pStr after "
+ "changing its value: "
+ pStr); //Line 15
} //end stringBufferParameter //Line 16
} //Line 17