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

为什么无法调用类,运行提示"Syntax error on token 'new'"该怎么解决

2012-01-22 
为什么无法调用类,运行提示Syntax error on token new标点符号没有问题,求指教.import java.util.Scan

为什么无法调用类,运行提示"Syntax error on token 'new'"
标点符号没有问题,求指教.


import java.util.Scanner;








class Cal {

int couple;
int number,temp;

int calculation(int year){
number = 0;
if(year%2 == 0){couple = year / 2;}
else {couple = (year - 1)/2;}
for(int i = 0; i < couple; i++){
temp = (1 + year - 1 - 1 * i) * (year - 1 - 1 * i) / 2 + 1;
number = number + temp;
}
return number;
}

}









public class rabit {

public static void main(String[] args) {
int year_n;
System.out.println("Please enter a number of months:");
Scanner input = new Scanner(System.in);
year_n = input.nextInt();
Cal mm = new Cal;
int year = mm.calculation(year_n);
System.out.println("The rabbit number is : " + year );

}

}



[解决办法]
Cal mm = new Cal;
这一行改成 Cal mm = new Cal();
[解决办法]
规则,必须遵守。

热点排行