while循环非法启动类型问题

时间:2015-09-21 20:27:56

标签: java loops while-loop

嘿,我得到的错误是,在while循环的开头,这是一个非法的类型开头的数据:

public class hello {

    public static void main (String [] arg) {
        int sum1=sum(7, 13);
    }

    public static int sum(int x, int y) { 
        int z=0;
    }

    while (y > 0) {
        z = z + x; 
        y--;
    }

    return (z)
}
}

1 个答案:

答案 0 :(得分:1)

var result = query .ToList() //This will actually execute the query. .Select(x => new MarkingPeriodTerm() { MarkingPeriodGroupID = x.MarkingPeriodGroupID, MarkingPeriodGroupName = x.MarkingPeriodGroupName, SchoolMarkingPeriods = x.SchoolMarkingPeriods.Project().To<SchoolMarkingPeriod>(null).ToList() //Here we are executing the Project method on in-memory data }); 之后删除大括号,并在int z = 0后添加分号。

正如chenchuk所说,return (z)对于该方法来说是一个更正确的名称,所以我已经改变了。我在multiply循环内的评论中也提出了一个建议。

像这样:

while
相关问题