- 1:
- String aStr = "_One_";
- String bStr = aStr;
- bStr = aStr.trim();
- System.out.println("[" + aStr + "," + bStr + "]");
- [code]package cn.itcast.rubby;
- public class Test4 {
- public static void main(String[] args) {
- StringBuffer sb=new StringBuffer();
- sb.append("hello");
- StringBuffer sb1=new StringBuffer();
- sb1.append("world");
- change(sb,sb1);
- System.out.println("sb:"+sb);
- System.out.println("sb1:"+sb1);
-
- }
- public static void change(StringBuffer a,StringBuffer b)
- {
-
- StringBuffer sb2=new StringBuffer();
- sb2=a;
- a=b;
- b=sb2;
- }
- }
- [code]3:注意观察 和2的不同
- package cn.itcast.rubby;
- public class Test4 {
- public static void main(String[] args) {
- StringBuffer sb=new StringBuffer();
- sb.append("hello");
- StringBuffer sb1=new StringBuffer();
- sb1.append("world");
- change(sb,sb1);
- System.out.println("sb:"+sb);
- System.out.println("sb1:"+sb1);
-
- }
- public static void change(StringBuffer a,StringBuffer b)
- {
-
- StringBuffer sb2=new StringBuffer();
- sb2=a;
- a=b;
- b=sb2;
- b.append("java");
- }
- }
复制代码 [/code][/code] |
|