これが返されたもので、どのエラーかわかりません: シンボルが見つかりません
C:\Users\testuser\Desktop\TestFile.java:33: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class TestFile
C:\Users\testuser\Desktop\TestFile.java:33: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class TestFile
C:\Users\testuser\Desktop\TestFile.java:44: error: cannot find symbol
String[] tabs = prep.Split(" ");
^
symbol: method Split(String)
location: variable prep of type String
3 errors
これは私のコードです。
public class TestFile {
String[] preps = {
"about", "above", "across", "after", "against",
"along", "among", "around", "at", "before",
"behind", "below", "beneath", "beside", "between",
"by", "concerning", "down", "during", "except",
"for", "from", "in", "inside", "into",
"like", "near", "of", "onto", "out",
"over", "through", "to", "toward", "under",
"up", "upon", "with", "within", "without"
};
String[] errorpreps = {
"will", "would", "shall", "should", "can",
"could", "may", "might", "must",
};
String[] question = {
};
public static void main(String[] args) {
TestFile f = new TestFile();
f.generatecode("hi");
};
public String generatecode(String code){
Scanner sc = new Scanner(System.in);
String inp = sc.nextString();
String prep = "";
for (int i=0; i<preps.length+1; i++){ //retuns all inputed things into prep
prep = preps + preps[i] + " ";
}
String[] tabs = prep.Split(" "); //splits the inputed thing and puts it into tab
for (int f=1; f<tabs.length+1; f++){
String prox = tabs[f];
if(prox.contains(".")){
prep = "Found a .!";
} else if(prox.contains("?")){
prep = "Found a ?!";
} else if(prox.contains("!")){
prep = "Found a !!";
} else if(prox.contains(",")){
prep = "Found a ,!";
}
}
return prep;
}
public String printcode(String code){
return "";
}
}
さて、私はスキャナーについてあまり知りません。私は何もインポートしませんでした。私は分割方法についていくつか知っています。構文が正しくない理由がわかりません。他の例から外れているのは正しい構文だと思います。
前もって感謝します。