输入一个字符串:
public class Example3 {
public static void main(String args[])
{
char ch = ' ';
System.out.println("please input a characheter.");
try
{
ch = (char)System.in.read();
}catch(IOException e){}
System.out.println("characheter is"+ch+"the ASCII value is"+(int)ch+"the 'c' is"+'c');
}
}
输入一个字符串:
public class Example3 {
public static void main(String args[])
{
String str = "";
System.out.println("please input a string.");
try
{
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
str = buffer.readLine();
}catch(IOException e){}
System.out.println("the String is"+str);
}
}