国企老总吃女下属奶:用JAVA语言编写数据的输入输出过程

来源:百度文库 编辑:神马品牌网 时间:2024/05/09 20:17:39

输入用这个类
import java.io.*;
class Input
{
public static int inputInt()
{
String str="";
try
{ BufferedReader i=new BufferedReader(new InputStreamReader(System.in));
str=i.readLine();
}
catch(Exception e)
{
System.out.println(e);
}
return Integer.parseInt(str);
}
public static double inputDouble()
{
String str="";
try
{ BufferedReader i=new BufferedReader(new InputStreamReader(System.in));
str=i.readLine();
}
catch(Exception e)
{
System.out.println(e);
}
return Double.parseDouble(str);
}
public static String inputString()
{
String str="";
try
{ BufferedReader i=new BufferedReader(new InputStreamReader(System.in));
str=i.readLine();
}
catch(Exception e)
{
System.out.println(e);
}
return str;
}

}
这个inputInt()函数是输入整数的,inputDouble()是输入实数,inputString()是输入字符串的。
输出就用
System.out.println("要输出的内容");

System.out.print("your word");