请问一个简单的问题,这里的say $+$getnumber表示什么意思? if (s.endsWith("say $+$getnumber")){Random random = new Random();randomNumber = random.nextInt(100);dos.writeUTF("产生了一个100以内的数");} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 一个猜字游戏:import java.io.DataInputStream;import java.io.DataOutputStream;import java.io.IOException;import java.util.*;import javax.swing.JTextArea;class ReadThread extends Thread{JTextArea ta;int randomNumber=-1;DataInputStream dis;DataOutputStream dos;public ReadThread(JTextArea t,DataInputStream d,DataOutputStream dos){this.ta = t;this.dis =d;this.dos = dos;}public void run(){int i=0;String s="";try{while(true){s =dis.readUTF();if (s.endsWith("say $+$getnumber")){Random random = new Random();randomNumber = random.nextInt(100);dos.writeUTF("产生了一个100以内的数");}if (!s.endsWith("太大了")&&!s.endsWith("太小了")&&!s.endsWith("产生了一个100以内的数")&&!s.endsWith("不是一个数字")&&!s.endsWith("say $+$getnumber")){System.out.println(s);try{int a = s.indexOf("say ");String ss = s.substring(a+4,s.length());i=Integer.parseInt(ss);}catch(NumberFormatException e){dos.writeUTF("不是一个数字");}if (i!=randomNumber){if(i>randomNumber){dos.writeUTF(i+"太大了");}else{dos.writeUTF(i+"太小了");}}else{dos.writeUTF(i+"对了");}}ta.append("I say: "+s); //accept the msgta.append("\n");} }catch(IOException e){System.out.println("conncttiong error");} } public int getRandomNumber(){return randomNumber;}} String s = "test" + "say $+$getnumber";System.out.println(s.endsWith("say $+$getnumber"));以上代码输出为:true这不就是说测试s是否以say $+$getnumber结尾吗? 关于 Ant 一段正则表达式,在perl下正常,在java下不行 求助:很简单的一个demo程序,只是我不会,求帮助,路过的都请留步,好吗? 残疾程序员的情感历程(原创)心情好,散分。。。 请原谅,问个问题,别笑我 :( 【诚恳求教】--如何用【TableModel】结合【JFileChooser】来更新【JTable】的内容?谢谢! 关于JAVA中的抓图 急!!!求计算两日期差值的代码 请教,如何继续学下去? 关于 java 浮点 算法优化问题 Java中得自己写实现delete功能的代码吗??? 小型java程序编程风格的讨论
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.*;import javax.swing.JTextArea;class ReadThread extends Thread{
JTextArea ta;
int randomNumber=-1;
DataInputStream dis;
DataOutputStream dos;public ReadThread(JTextArea t,DataInputStream d,DataOutputStream dos){
this.ta = t;
this.dis =d;
this.dos = dos;
}public void run(){
int i=0;
String s="";
try{
while(true){
s =dis.readUTF();if (s.endsWith("say $+$getnumber")){Random random = new Random();
randomNumber = random.nextInt(100);
dos.writeUTF("产生了一个100以内的数");
}
if (!s.endsWith("太大了")&&
!s.endsWith("太小了")&&
!s.endsWith("产生了一个100以内的数")&&
!s.endsWith("不是一个数字")&&
!s.endsWith("say $+$getnumber")){
System.out.println(s);
try{
int a = s.indexOf("say ");
String ss = s.substring(a+4,s.length());
i=Integer.parseInt(ss);
}
catch(NumberFormatException e){
dos.writeUTF("不是一个数字");
}if (i!=randomNumber){
if(i>randomNumber){
dos.writeUTF(i+"太大了");
}else{
dos.writeUTF(i+"太小了");
}
}else{
dos.writeUTF(i+"对了");
}}
ta.append("I say: "+s); //accept the msg
ta.append("\n");
}
}
catch(IOException e){
System.out.println("conncttiong error");
}
}
public int getRandomNumber(){
return randomNumber;
}}
System.out.println(s.endsWith("say $+$getnumber"));以上代码输出为:true
这不就是说测试s是否以say $+$getnumber结尾吗?