我试图得到基于一个简单的算法,一个数组的元素。在这个例子中,我得到它的指标和两个(单元三)我写的方法,但用jcreator给我“return语句缺少”的元素。我该如何解决这个问题。return语句是缺少错误阵列
public class hw1 {
public static void main(String[] args) {
String[][] RaggedArray = {
{ "hello", "hi", "i", "nice", "good", "love" },
{ "what", "java", "there" },
{ "and", "cool", "door", "my" },
{ "time", "phone", "homework" }
};
System.out.println(hw_one(RaggedArray));
}
public static String hw_one(String[][] array) {
String result;
for (int row = 0; row < array.length; row++) {
for (int column = 0; column < array[row].length; column++) {
if ((row + column) % 3 == 2) {
result = array[row][column];
}
}
}
return result;
}
}
请之前发布格式化你的代码。这是非常难以阅读的。 – jlordo
Ÿ是,我RLY是需要对其进行格式化...... – SomeJavaGuy