isSorted.java:9: cannot resolve symbol
symbol : class Scanner
location: package util
java.util.Scanner scan = java.util.Scanner.create(System.in)
^
isSorted.java:9: cannot resolve symbol
symbol : class scanner
location: package util
java.util.Scanner scan = java.util.Scanner.create(System.in)
为什么啊???
10 个解决方案
#1
给出原码,不在怎么看!
#2
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();
}
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();
}
#3
未找到java.util包的Scanner类。
1、检查你的classpath设置是否正确。
2、另外java.util包中好像没有Scanner类。 -_-!
1、检查你的classpath设置是否正确。
2、另外java.util包中好像没有Scanner类。 -_-!
#4
原码:
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的问题么?
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的问题么?
#5
input.java:8: unreported exception java.io.IOException; must be caught or declared to be thrown
意思是要抛出一个异常,但是没有被捕获。
一般的I/O操作都回抛出一个IOException异常
意思是要抛出一个异常,但是没有被捕获。
一般的I/O操作都回抛出一个IOException异常
#6
应该这样写:
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) {}
}
}
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) {}
}
}
#7
也可以这样,不过我认为没有上面方法好:
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);
}
}
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);
}
}
#8
nreported exception java.io.IOException;
must be caught or
declared to be thrown(或者throws IOException)
must be caught or
declared to be thrown(或者throws IOException)
#9
对于第一个问题:
import java.io.*;
...
为什么只导入io包,后面要用到java.util.Scanner类,还要加上
import java.util.*;
import java.io.*;
...
为什么只导入io包,后面要用到java.util.Scanner类,还要加上
import java.util.*;
#10
学习,学习
#1
给出原码,不在怎么看!
#2
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();
}
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();
}
#3
未找到java.util包的Scanner类。
1、检查你的classpath设置是否正确。
2、另外java.util包中好像没有Scanner类。 -_-!
1、检查你的classpath设置是否正确。
2、另外java.util包中好像没有Scanner类。 -_-!
#4
原码:
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的问题么?
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的问题么?
#5
input.java:8: unreported exception java.io.IOException; must be caught or declared to be thrown
意思是要抛出一个异常,但是没有被捕获。
一般的I/O操作都回抛出一个IOException异常
意思是要抛出一个异常,但是没有被捕获。
一般的I/O操作都回抛出一个IOException异常
#6
应该这样写:
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) {}
}
}
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) {}
}
}
#7
也可以这样,不过我认为没有上面方法好:
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);
}
}
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);
}
}
#8
nreported exception java.io.IOException;
must be caught or
declared to be thrown(或者throws IOException)
must be caught or
declared to be thrown(或者throws IOException)
#9
对于第一个问题:
import java.io.*;
...
为什么只导入io包,后面要用到java.util.Scanner类,还要加上
import java.util.*;
import java.io.*;
...
为什么只导入io包,后面要用到java.util.Scanner类,还要加上
import java.util.*;
#10
学习,学习