java小程序(3)
//-------------------输入输出--------------------------------------
package exercise;
import java.io.*;
public class CharIn
{
/**
* 单个字符的输入输出!
**/
// public static void main (String[] args)
// {
// char c = ' ';
// System.out.print("请输入: "); // char
// try{
// c = (char) System.in.read();
// }catch(IOException e){}
// System.out.print("您刚才输入的是:" + c); // entered
// }
/**
* 字符串的输入输出!
**/
//public static void main (String[] args)
//{
//String s = "";
//System.out.print("please input a line:");
//try{
//BufferedReader in = new BufferedReader(
//new InputStreamReader (System.in));
//s = in.readLine();
//}catch(IOException e){}
//System.out.print("You hava entered :" + s);
//}
/**
* 数字的输入与输出
* **/
public static void main (String[] args)
{
String s= "";
int n = 0;
double d = 0;
try{
BufferedReader in = new BufferedReader(
new InputStreamReader (
System.in));
System.out.print("Please input an int:");
s = in.readLine();
n = Integer.parseInt(s);
System.out.print("Please input a double: ");
s = in.readLine();
d = Double.parseDouble(s);
}catch(IOException e){}
System.out.print("you hava entered: " + n + "and" + d);
}
}