读取的字符可以使用Integer.parseInt(int param)转换
System.out.println("输入的数据为:"+s);素数自己看一看书吧,很多书都有.

解决方案 »

  1.   

    import java.io.*;class Demo1128_1 
    {
    public static boolean isPrime(int in)
    {
    if(in%2==0&&in!=2)return false;
    if(in==1)return false;
    for(int i=3;i<Math.sqrt(in);i+=2)
    if (in%i==0)return false;
    return true;
    }
    public static void main(String[] args) 
    throws IOException
    {
    int in=0;
    boolean Flag=true;
    String s;
    while(Flag)
    {
    System.out.println("Please input the number from 1 to 10000,0 to exit!");
    BufferedReader c=new BufferedReader(new InputStreamReader(System.in));
    s=c.readLine();
    in=Integer.parseInt(s);
    if(in==0)
    Flag=false;
    else
    if(isPrime(in))
    System.out.println(in+" is a prime number!");
    else
    System.out.println(in+" isn't a prime number!");
    }
    }
    }
      

  2.   

    你直接看一下system的类库
    public int read(byte b[]) throws IOException {
    public int read(byte b[], int off, int len) throws IOException {
    public abstract int read() throws IOException;
    这是3种读的方法!很清楚他是什么东西了!
    那么println()
    public void println(long x) {
    ...
    ...
    很多重载方法
    你打印基本数据类型都可以!
    阿且其他的飞机本类型你载println其实都有一个toString()方法的!
    基本都可以println