我想要在System.out.println("你输入的是:"+s);
后面加条if语句是说明如果输入exit就退出该程序不知道该怎么写
请指教谢谢
package untitled1;
import java.io.*;
public class ying{
public static void main(String arg[]){
String s=" ";
try{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.print("请输入一个字符:");
s=in.readLine();
}catch(IOException e){}
System.out.println("你输入的是:"+s);
}
}
后面加条if语句是说明如果输入exit就退出该程序不知道该怎么写
请指教谢谢
package untitled1;
import java.io.*;
public class ying{
public static void main(String arg[]){
String s=" ";
try{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.print("请输入一个字符:");
s=in.readLine();
}catch(IOException e){}
System.out.println("你输入的是:"+s);
}
}
System.out.print("请输入一个字符:");
s=in.readLine();
if(s.equals("exit"))
return;
{
System.exit(0);
}
if(s.equals("exit") System.exit(0);
public class ying{
public static void main(String arg[]){
String s=" ";
try{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.print("ÇëÊäÈëÒ»¸ö×Ö·û:");
s=in.readLine();
}catch(IOException e){}
System.out.println("ÄãÊäÈëµÄÊÇ:"+s);
if(s.equals("exit")){
System.exit(0);
}
}
}
import java.io.*;
public class ying{
public static void main(String arg[]){
String s=" ";
try{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.print("请输入一个字符:");
s=in.readLine();
}catch(IOException e){}
if(String.valueOf(s.trim()).equals("exit")
System.exit(0);
else
System.out.println("你输入的是:"+s);
}
}