0

私のコードの一部を以下に示します。(ステートメント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.
4

1 に答える 1

1

メソッド内にしか持てないので、そのコードの一部をメソッドに入れる必要がありますif

例えば

public class AClass {
    void aMethod() {
        if( true == true ) {
            //do something
        }
    }
}
于 2012-10-14T08:21:01.180 に答える