分类:java share 发布 2009.03.30 00:03:48Tag : java,php,equals commentComment:0
2
dig bury

终于学会怎么使用java手册了,先要查找类,然后在使用ctrl+f查找所要查找的方法

php的手册可以直接查找着这点使用起来十分方便

关于字符串对比,php中可以直接使用等号(==),而java中竟然要使用equals进行对比,使用==无法得到正确的结果


public class lesson7 {
public static void main(String [] args)
{
byte [] buf = new byte[1024];
String strInfo = null;
int pos = 0;
int ch = 0;
System.out.print("please enter info:");
while(true)
{
 try
 {
  ch = System.in.read();
 }catch(Exception e){e.printStackTrace();}
 switch(ch)
 {

 break;

 strInfo = new String(buf,0,pos);
 if(strInfo.equals("bye"))
 {
  return;
 }else{
  System.out.print(strInfo);
  pos=0;
  break;
 }
 default:
  buf[pos++] = (byte)ch;
 }
}
}
}
 

我也来说2句,请不要发表违反法律的言论

姓名

Email(必填)

主页(不要加http://)