msg!="ServerExits!"
用!msg.equal("ServerExits!")
试试看
用!msg.equal("ServerExits!")
试试看
解决方案 »
- 找不到main方法!!!!
- 实现固定长度的java.util.Queue
- 高分求助----关于java生成缩略图的问题!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 怎样做一个自己的程序包?
- 求short转byte[]方法?为啥有的可以,有的不可以?
- 关于DOS命令,来帮我
- 我用jdbc连接db2插入clob字段结果抛出这样的异常
- 各位,如果使程序常驻内存,就像一些杀毒软件一样
- 我知道它在第几行,但我怎样返回它的值呢?很急呀!!!
- 我找不到JBuilder3.5(或4)的企业版下载点,请热心者帮帮忙!
- 偶想学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++中,你可以自己定义这些。