import java.io.*;public class isSorted
{
  public static int n;
  public static int[] m;
  public static void main(String[] args)
  {
    java.util.Scanner scan = java.util.Scanner.create(System.in);
    int len;
    
    m = new int[20];
    len=scan.nextInt();
    
    for(int i=0; i<len; i++)
     m[i]=scan.nextInt();
    
}

解决方案 »

  1.   

    未找到java.util包的Scanner类。
    1、检查你的classpath设置是否正确。
    2、另外java.util包中好像没有Scanner类。 -_-!
      

  2.   

    原码:
    import java.io.*;public class input{
       public void main(String args[]){
           BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
           String s;
           System.out.println("输入一个字符!");
           s=br.readLine();
           System.out.println("s:  "+s);
       }
    }错误:
    D:\JAVA\programs>javac input.java
    input.java:8: unreported exception java.io.IOException; must be caught or declar
    ed to be thrown
           s=br.readLine();
                        ^
    1 error
    难道是CLASSPATH的问题么?
      

  3.   

    input.java:8: unreported exception java.io.IOException; must be caught or declared to be thrown意思是要抛出一个异常,但是没有被捕获。
    一般的I/O操作都回抛出一个IOException异常
      

  4.   

    应该这样写:import java.io.*;public class input{
       public void main(String args[]){
           try {
             BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
             String s;
             System.out.println("输入一个字符!");
             s=br.readLine();
             System.out.println("s:  "+s);
           } catch (Exception ex) {}
       }
    }
      

  5.   

    也可以这样,不过我认为没有上面方法好:public class input{
       public void main(String args[]) throws IOException{
           BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
           String s;
           System.out.println("输入一个字符!");
           s=br.readLine();
           System.out.println("s:  "+s);
       }
    }
      

  6.   

    nreported exception java.io.IOException;
           must be caught or 
          declared to be thrown(或者throws IOException)
      

  7.   

    对于第一个问题:import java.io.*;
    ...为什么只导入io包,后面要用到java.util.Scanner类,还要加上
    import java.util.*;