Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么Java告诉我a';)';表达式的开头是否非法?_Java - Fatal编程技术网

为什么Java告诉我a';)';表达式的开头是否非法?

为什么Java告诉我a';)';表达式的开头是否非法?,java,Java,因此,我假设编写一个应用程序,读取以小时、分钟和秒为单位的时间值。然后以秒为单位打印相同的时间。(例如,1小时28分42秒等于5322秒)我使用JCreator,当我尝试编译时,它告诉我在第21行有2个错误,这是 System.out.println(“您的答案等于=”+时间“秒”); 它告诉我的错误是“')是表达式的预期和非法开始 import java.util.Scanner; public class StackOverflow.swag // for teh lulz

因此,我假设编写一个应用程序,读取以小时、分钟和秒为单位的时间值。然后以秒为单位打印相同的时间。(例如,1小时28分42秒等于5322秒)我使用JCreator,当我尝试编译时,它告诉我在第21行有2个错误,这是
System.out.println(“您的答案等于=”+时间“秒”); 它告诉我的错误是“')是表达式的预期和非法开始

 import java.util.Scanner;
    public class StackOverflow.swag // for teh lulz
    {
        public static void main (String [] args);
        {
            double time, hours, minutes, seconds;
            seconds = 0.0;
            minutes = minutes*3600;
            hours = hours*216000;
            time = seconds+minutes+hours;
            Scanner scan = new Scanner (System.in);

            System.out.println ("Enter number of hours");
            hours = scan.nextDouble();
            System.out.println ("Enter number of minutes");
            minutes = scan.nextDouble();
            System.out.println ("Enter number of seconds");
            seconds = scan.nextDouble();


            System.out.println ("Your answer equals =" +time+ "seconds");


        }
    }

时间
秒之间缺少
+
。改变

System.out.println ("Your answer equals =" +time "seconds");

另外,在
main
方法签名后还有一个分号,语法不正确。改变

public static void main (String [] args);


当我这样做时,它会在第行告诉我“缺少方法体,或者声明抽象”4@Sam分号不应该在那里;看我更新的答案。是的,我这么做了,但后来我意识到我也过早地设置了变量的值,所以我现在就让它工作了。
public static void main (String [] args);
public static void main (String [] args)