gpt4 book ai didi

java - 编译错误: '.class' expected

转载 作者:行者123 更新时间:2023-12-01 18:27:43 24 4
gpt4 key购买 nike

String sAge = scan.nextLine();
Scanner scan = new Scanner( System.in );

System.out.print( "what year were you born? >");
int iAge = scan.nextInt (sAge);
final double Cyear = 2014;
final double LEmax = 77.9;

System.out.println( "\nThe percentage of your life you have lived is " + int LEmax );

当我编译这个时,我收到以下错误:

C:\Users\PracticeMethods.java:54: error: '.class' expected
System.out.println( "\nThe percentage of your life you have lived is " + int LEmax );
^
C:\Users\PracticeMethods.java:54: error: ';' expected
System.out.println( "\nThe percentage of your life you have lived is " + int LEmax );

我做错了什么?你能帮我解决这些错误吗?

最佳答案

这只是一个语法错误。试试这个:

System.out.println( "\nThe percentage of your life you have lived is " + LEmax );

请注意,您不必再次说LEmax是一个int,我们仅在声明时指定变量的类型它,而不是我们使用它时。或者也许你打算选角?如果是这样的话,那么你应该这样写,将类型括在 ():

之间
System.out.println( "\nThe percentage of your life you have lived is " + (int) LEmax );

关于java - 编译错误: '.class' expected,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25468325/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com