import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class RunTest {
public static void main(String[] args) throws IOException {
while(true){
System.out.println("There are three choice :1 2 3");
System.out.println("Please Enter your choice:");
BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
String name = br.readLine();
if( "1".equals(name)){
System.out.println("Your choice is 1");
}
if ("2".equals(name))
{
System.out.println("Your choice is 2");
}
if ("3".equals(name))
{
System.out.println("Your choice is 3");
}
}
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class RunTest {
public static void main(String[] args) throws IOException {
while(true){
System.out.println("There are three choice :1 2 3");
System.out.println("Please Enter your choice:");
BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
String name = br.readLine();
if( "1".equals(name)){
System.out.println("Your choice is 1");
}
if ("2".equals(name))
{
System.out.println("Your choice is 2");
}
if ("3".equals(name))
{
System.out.println("Your choice is 3");
}
}
}
}
本文介绍了一个简单的Java程序示例,该程序通过控制台接收用户的输入,并根据用户的选择显示不同的反馈信息。使用了BufferedReader类从标准输入读取一行文本。
62

被折叠的 条评论
为什么被折叠?



