import java.io.*;
public class ReadHello
{ public static void main(String args[])
{ String s;
System.out.println("Enter characters:");
try{ s=(String)System.in.read();
System.out.println(""+ s);
}catch(IOException e)
{ Sytem.out.println("Error reading from user");
}
}
}
7 个解决方案
#1
你这个需要还是用Scanner做比较合适,给你写一段实例代码
也不用怀念什么C C++只是你对java还不了解而已
也不用怀念什么C C++只是你对java还不了解而已
import java.io.*;
import java.util.Scanner;
public class ReadHello{
public static void main(String args[]){ String s;
System.out.println("Enter characters:");
Scanner scanner=new Scanner(System.in);
s=scanner.nextLine();
System.out.println("刚刚的输入是"+ s);
}
}
#2
up...
#3
up...
#4
import java.io.*;
import java.util.Scanner;
public class ReadHello{
public static void main(String args[]){ String s;
System.out.println("Enter characters:");
Scanner scanner=new Scanner(System.in);
s=scanner.nextLine();
System.out.println("刚刚的输入是"+ s);
}
}
import java.util.Scanner;
public class ReadHello{
public static void main(String args[]){ String s;
System.out.println("Enter characters:");
Scanner scanner=new Scanner(System.in);
s=scanner.nextLine();
System.out.println("刚刚的输入是"+ s);
}
}
#5
原来是用最基本的东西就可以解决的。
#6
import java.io.Console;
Console console = System.console();
if(console != null){
String text = console.readLine("%s","Please input your name:");
}
#7
用Scanner 是不错。也可以使用流
public class DataInputStreamextends FilterInputStreamimplements DataInput
public class DataInputStreamextends FilterInputStreamimplements DataInput
#1
你这个需要还是用Scanner做比较合适,给你写一段实例代码
也不用怀念什么C C++只是你对java还不了解而已
也不用怀念什么C C++只是你对java还不了解而已
import java.io.*;
import java.util.Scanner;
public class ReadHello{
public static void main(String args[]){ String s;
System.out.println("Enter characters:");
Scanner scanner=new Scanner(System.in);
s=scanner.nextLine();
System.out.println("刚刚的输入是"+ s);
}
}
#2
up...
#3
up...
#4
import java.io.*;
import java.util.Scanner;
public class ReadHello{
public static void main(String args[]){ String s;
System.out.println("Enter characters:");
Scanner scanner=new Scanner(System.in);
s=scanner.nextLine();
System.out.println("刚刚的输入是"+ s);
}
}
import java.util.Scanner;
public class ReadHello{
public static void main(String args[]){ String s;
System.out.println("Enter characters:");
Scanner scanner=new Scanner(System.in);
s=scanner.nextLine();
System.out.println("刚刚的输入是"+ s);
}
}
#5
原来是用最基本的东西就可以解决的。
#6
import java.io.Console;
Console console = System.console();
if(console != null){
String text = console.readLine("%s","Please input your name:");
}
#7
用Scanner 是不错。也可以使用流
public class DataInputStreamextends FilterInputStreamimplements DataInput
public class DataInputStreamextends FilterInputStreamimplements DataInput