【发布时间】:2021-12-08 15:44:42
【问题描述】:
public static int countPopular(int count0, int count1, int count2) {
int result;
if (count0 > count1 && count0 > count2) {
result = 0;
}
else if (count1 > count0 && count1 > count2) {
result = 1;
}
else if (count2 > count0 && count2 > count1) {
result = 2;
}
else {
result = -1;
}
return result;
}
在确定我在这个多块语句中缺少括号的位置时遇到问题。
Message: '}' at column 7 should be on the same line as the next part of a multi-block statement (one that directly contains multiple blocks: if/else-if/else, do/while or try/catch/finally).
Line: 28 Message: '}' at column 7 should be on the same line as the next part of a multi-block statement (one that directly contains multiple blocks: if/else-if/else, do/while or try/catch/finally).
Line: 32 Message: '}' at column 7 should be on the same line as the next part of a multi-block statement
这些是我收到的错误消息。
【问题讨论】:
-
请解释是什么错误信息或行为让您认为括号是错误的。
-
它要求您将 if else/else 语句与最后一条语句的右括号放在同一行。
-
那些不是错误。 Checkstyle 告诉你你的代码不符合它应该遵循的约定。
-
你应该知道这不是语言的要求;这只是一些人(不是我)喜欢的风格。
标签: java checkstyle