当前位置: 代码迷 >> J2SE >> 为什么无法调用类,运行提示"Syntax error on token 'new'"该怎么解决
  详细解决方案

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

热度:148   发布时间:2016-04-24 12:33:21.0
为什么无法调用类,运行提示"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();
------解决方案--------------------
规则,必须遵守。
  相关解决方案