public class Reverse {
public static void main(String [] args){
System.out.println(reverse(array));
String[] array = {"I","L","O","V","E","Y","O","U"};
}
public static String reverse(String phrase){
for(int i = phrase.length()-1; i >= 0; i--){
System.out.println(phrase.charAt(i));
}//end of loop
return phrase;
}//end of second class
}//end of reverse class
答案 0 :(得分:1)
您发布的代码存在很多问题
function MyConstructor() {}
MyConstructor.prototype = {};
var myobject = new MyConstructor();
console.log(myobject instanceof MyConstructor);
console.log(Object.getPrototypeOf(myobject) === MyConstructor.prototype);
MyConstructor.prototype = {};
console.log(myobject instanceof MyConstructor);
console.log(Object.getPrototypeOf(myobject) === MyConstructor.prototype);
,但是返回值为String
String[]
=> phrase.length()
为了更好地理解,我建议您here,并阅读您尝试在阵列上使用的所有方法的文档。
这是您的代码,按我想的那样工作:
phrase.length
答案 1 :(得分:0)
您的代码中存在逻辑错误。我不会告诉您解决方案,而是要指出几件事: