由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - java String
相关主题
Help: web service questions说说clone咋违反了类继承的原则来的?
折腾了一天,实在是绝望了,请教请教两个很基本的JAVA问题
overloading methodsjdbc连接数据库出现的问题
求教jbuilder的问题新手求助,急急急!!!
继续问土问题help "java.lang.NoSuchMethodError"
how to map one to many relation for a single table in hibe不用main(String args[]),怎样输出"hello world"?
How to get a matched String?Re: 怎样不用main(String args[])输出"hello worl
Re: how to initialize corba object orb in servlet请帮忙看看这个编译错误
相关话题的讨论汇总
话题: string话题: str话题: what话题: same话题: object
进入Java版参与讨论
1 (共1页)
h*****l
发帖数: 2
1
May I ask what method is used to copy a String to another?
s**h
发帖数: 17
2
use = operator directly ah...

【在 h*****l 的大作中提到】
: May I ask what method is used to copy a String to another?
g*s
发帖数: 2277
3

it will point to same object lah.use constructor or substring.

【在 s**h 的大作中提到】
: use = operator directly ah...
s**h
发帖数: 17
4
oh...I thought it was ok to point to the same object:)

【在 g*s 的大作中提到】
:
: it will point to same object lah.use constructor or substring.

b****r
发帖数: 53
5
String s1="abc";
String s2= new String(s1)
then change of s2 will not affect s1
在 huangzl (gossip) 的大作中提到: 】
s**h
发帖数: 17
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 的大作中提到】
: String s1="abc";
: String s2= new String(s1)
: then change of s2 will not affect s1
: 在 huangzl (gossip) 的大作中提到: 】

f****u
发帖数: 12
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 的大作中提到】
: 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

w*********n
发帖数: 84
8
hehe, it's now quite complicated.
I prefer the simple solusion. such, barber's.

【在 f****u 的大作中提到】
: 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);

1 (共1页)
进入Java版参与讨论
相关主题
请帮忙看看这个编译错误继续问土问题
请教一个简单的问题how to map one to many relation for a single table in hibe
简单问题How to get a matched String?
interestingRe: how to initialize corba object orb in servlet
Help: web service questions说说clone咋违反了类继承的原则来的?
折腾了一天,实在是绝望了,请教请教两个很基本的JAVA问题
overloading methodsjdbc连接数据库出现的问题
求教jbuilder的问题新手求助,急急急!!!
相关话题的讨论汇总
话题: string话题: str话题: what话题: same话题: object