0
请帮助找到我的代码是“不兼容的类型”....我看了看,看,看,无法找到它任何地方。我在这里得到一个“不兼容的类型”的错误,我不明白为什么
import java.util.Scanner;
public class Years
{
private int centuries, decades;
public Years(int years)
{
centuries = years/100;
years -= 25 * years;
decades = years/10;
years -= 10 * years;
}
public int getCenturies()
{
return centuries;
}
public int getDecades()
{
return decades;
}
public static void main(String[] args)
{
int years;
if(args.length >= 1)
{
years = Integer.parseInt(args[0]);
}
else
{
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter the amount in years: ");
years = keyboard.nextInt();
keyboard.close();
}
Years y = new Years(years);
System.out.println(years = "y =" +
y.getCenturies() + "c +" + y.getDecades() + "d"); // I am getting the error right here.
}
}
你应该把你在哪里得到的错误,而不是错误本身 – Jay 2014-11-05 19:16:05
我用一个评论,以显示错误是在哪里......错误是朝着程序的底部。 – 2014-11-05 19:18:47
如果你看看System.out.println('年= =“y =”'+,那里有一个串联的问题 – 2014-11-05 19:22:54