急!!javac编译找不到符号!

[复制链接]
查看11 | 回复3 | 2010-9-23 15:09:05 | 显示全部楼层 |阅读模式
很简单的一段程序:
import java.util.Scanner;
public class int_sum {



public static void main(String[] args) {
System.out.println("please enter an integer: ");
Scanner sacnner=new Scanner(System.in);
int x=scanner.nextInt();
int i=x,sum=0;
while(i!=0){

sum+=i%10;

i=i/10;
}

System.out.println("sum of the number is");

}
}
编译的时候老说在int x=scanner.nextInt();找不到符号?请问为什么呀?疯了都。。

回复

使用道具 举报

千问 | 2010-9-23 15:09:05 | 显示全部楼层
import java.util.Scanner;public class int_sum { public static void main(String[] args) {System.out.println("please enter an integer: ");Scanner scanner = new Scanner(System.in);//这里变量名称错误int x = scanner.nextInt();int i = x, sum = 0;while (i != 0) { sum += i % 10; i = i / 10;}System
回复

使用道具 举报

千问 | 2010-9-23 15:09:05 | 显示全部楼层
Scanner sacnner=new Scanner(System.in);你写错了,这个变量。。。
回复

使用道具 举报

千问 | 2010-9-23 15:09:05 | 显示全部楼层
看下自己写的scanner对不对?你申明的对象是 sacnner而用的是scanner
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行