msg!="ServerExits!"
用!msg.equal("ServerExits!")
试试看
用!msg.equal("ServerExits!")
试试看
解决方案 »
- eclipse中错误
- java读取txt文件的问题,各位来看看
- java读取机器的IP地址
- 求助~~~帮我看看这个计算器
- 怎样将string类型转化为数值型
- 关于getParameterValues方法和动态数组与集合的问题求教
- statement 执行execute来进行数据的插入如何判断插入结果是否正常? 如果使用executeUpdate又怎么做?
- 求求大家帮帮我啊~!谢谢了啊~
- To masterz():高手,您能不能说具体一点,怎样“在BufferedImage/Image对象上写字“?
- value = value == null 这个语法 何解???
- 偶想学java,请各位达人指点一二
- 好像JDK 1.4在Solaris上有严重的字符集Bug!!!!欢迎大家讨论!!!
while(msg.indexOf("ServerExits!")<0){
...
}
如下:
String str1="china";
String str2="china";
if(str1==str2)
System.out.println("they are the same object!");
else
System.out.println("they are not the same object!");
我不知道定义的这两个String对象算不算同一个对象?
反正结果是they are the same object!
顺便问一下"System.out"这是在哪个包下面啊?怎么找不到呢?
System是在java.lang.System包中
while(msg!="ServerExits!")
改成
while(msg.equal("ServerExits!"))
String str1="china";
String str2="china";
if(str1==str2)
System.out.println("they are the same object!");
else
System.out.println("they are not the same object!");str1应该和str2不是同一个对象吧,可是运行结果是"they are the same object!"
这是什么原因呢?把这个问题解决,马上揭帖!再次谢谢大家
如C++中有重载运算符。其实Java本身也运用了这个东东。
如:String a = "a";
一个类是不能直接和一个字串相相等的。当出现"="符号时,其实,它运行了String中的一个function ,把"a"赋给String中的一个私有变量。
String类中,类似的还有:“+”等等。
在C++中,你可以自己定义这些。