java不断得到非法的类型错误的开始,我如何才能纠正这一点并继续前进?
下面是我的部分代码;由于常量illegal start of type
错误(在if
语句的行上),我无法编译。我能做些什么来改变它
public class Job
{
boolean jobsCompleted = false;
Job firstJob = getCurrentJob();
String jobName = firstJob.getName();
int jobDuration = firstJob.getDuration();
if (!myJob.isEmpty()&& jobDuration > 0 && jobDuration <= myTotalDuration)
//this is where i am getting the error, highlighting red before the 'if' statement.
# 1 楼答案
您需要将其中一些代码放入一个方法中,因为在一个方法中只能有一个
if
比如