use*_*460 3 java compiler-construction compiler-errors
所以,这太烦人了.
我制作了2个节目.
1号 :
class Arrays2 {
public static void main(String[] args){
String sentenceBest[] = {"This is the first sentence!"};
char chR[] = sentenceBest.toCharArray();
for (int counter = 0; counter < chR.length; counter++){
char now = chR[counter];
if (now != ' ') {
System.out.println(now);
}else {
System.out.println('.');
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
对于这个程序,它说:
Arrays_ToCjarArray(not working).java:6: cannot find symbol
symbol : method toCharArray()
location: class java.lang.String[]
char chR[] = sentenceBest.toCharArray();
^
1 error
Run Code Online (Sandbox Code Playgroud)
编号#2计划:
class Arrays_3 {
public static void main(String[] args){
boolean numbers[] [] = new boolean[10] [10];
numbers[9] [8] = true;
System.out.println(numbers[9][8] + "!!!");
String names[] = {"Marton", "Balint", "Thomas", "David", "John", "Peter", "Andy", "Daniel", "Josh", "James", "Erling", "Romeo", "Vincent", "Fabian"};
System.out.println("The origional order: ");
for (int counter = 0; counter < names.length; counter++){
String newName = names[counter];
System.out.println(counter + ": " + newName);
}
System.out.println("The Alphabetical order: ");
Arrays
for (int counter2 = 0; counter2 < names.length; counter2++) {
System.out.println(counter2 + ": " + names);
}
}
}
Run Code Online (Sandbox Code Playgroud)
同样的事情.找不到标志.太烦人了
Arrays_3.java:21: cannot find symbol
symbol : variable Arrays
location: class Arrays_3
Arrays.sort(names);
^
1 error
Run Code Online (Sandbox Code Playgroud)
我真的不明白这个,因为这个源代码来自一本名为Sams的伟大(迄今为止)的书,在24小时内教你Java.所以我真的不明白这一点.任何帮助都会很好.
1. toCharArray()
是String
不是String[]
你需要Arrays
通过添加来导入
import java.util.Arrays;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7193 次 |
最近记录: |