[英]Why is there error on System.out.print(rev);?
public static void main(String[] args) {
// TODO Auto-generated method stub
String rev = "";
String input = "Hello World";
int length = input.length();
for (int i = length - 1; 1 >= 0; i--){
rev = rev + input.charAt(i);
}
System.out.print(rev);
Assuming you've copy and pasted that block and code, the error is because System.out.print(rev);
假设您已经复制并粘贴了该块和代码,则该错误是因为System.out.print(rev);
has been placed outside the main()
function block. 已放置在main()
功能块之外。
String str = "Welcome Java";
char[] strArray = str.toCharArray();
for (int i = strArray.length-1; i >=0 ; i--) {
System.out.print(strArray[i]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.