b*r
5 楼
String s1="abc";
String s2= new String(s1)
then change of s2 will not affect s1
在 huangzl (gossip) 的大作中提到: 】
String s2= new String(s1)
then change of s2 will not affect s1
在 huangzl (gossip) 的大作中提到: 】
s*h
6 楼
String s, t;
s="what are you doing?";
t="what what what";
System.out.println(t);
t=s;
System.out.println(t);
s="1.12.2.2.2.2";
System.out.println(t);
output:
what what what
what are you doing?
what are you doing?
hehe
【在 b****r 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: String s1="abc";
: String s2= new String(s1)
: then change of s2 will not affect s1
: 在 huangzl (gossip) 的大作中提到: 】
s="what are you doing?";
t="what what what";
System.out.println(t);
t=s;
System.out.println(t);
s="1.12.2.2.2.2";
System.out.println(t);
output:
what what what
what are you doing?
what are you doing?
hehe
【在 b****r 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: String s1="abc";
: String s2= new String(s1)
: then change of s2 will not affect s1
: 在 huangzl (gossip) 的大作中提到: 】
f*u
7 楼
class Str {
String str;
}
class HelloWorldApp {
public static void main(String[] args) {
Str s=new Str();
Str t=new Str();
s.str="1";
t.str="2";
System.out.println(t.str);
t=s;
System.out.println(t.str);
s.str="3";
System.out.println(t.str);
}
}
The result is:
2
1
3
If u use "=" to assiagn class2 to class1, both 1 and 2 contain the same
reference--point to the same object. This phenomenon is called "aliasing
【在 s**h 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: String s, t;
: s="what are you doing?";
: t="what what what";
: System.out.println(t);
: t=s;
: System.out.println(t);
: s="1.12.2.2.2.2";
: System.out.println(t);
: output:
: what what what
String str;
}
class HelloWorldApp {
public static void main(String[] args) {
Str s=new Str();
Str t=new Str();
s.str="1";
t.str="2";
System.out.println(t.str);
t=s;
System.out.println(t.str);
s.str="3";
System.out.println(t.str);
}
}
The result is:
2
1
3
If u use "=" to assiagn class2 to class1, both 1 and 2 contain the same
reference--point to the same object. This phenomenon is called "aliasing
【在 s**h 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: String s, t;
: s="what are you doing?";
: t="what what what";
: System.out.println(t);
: t=s;
: System.out.println(t);
: s="1.12.2.2.2.2";
: System.out.println(t);
: output:
: what what what
相关阅读
git question有没有大牛在搞cloud?-- 包子贴Oracle Webinar hosted by CINAOUG on July 18, 2011 (转载)GAE 的一些问题就是这样,附图help with yourkit?JVM freeze初学java谁给推荐一本入门书现在写代码还有人开着API么?spring web service issue免费$500或2次往返机票offer Sapphire Preferred Cardplease recommend a good Java Hosting service考过SCJP的请进来!求救求救 JSObject的getWindow为什么总是返回null呀~a faster sortedMap than treemap ?有人在 Win7 上用 Tomcat 吗?问个初级的generic的问题学了点java,求兼职之类的。how to debug SEGV of JVM ?some simple matters take a long long time to have a solution