首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

java小程序(三)

2012-10-29 
java小程序(3)//-------------------输入输出-------------------------------------- package exercisei

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);
}
}

热点排行