表达式的非法启动-Java



为什么我得到:表达式的非法开始-public static int noOfLetters(String str({error?我该如何修复它?

public class Mmn15 {
public static int digInNumFor(int num, int dig) {
Scanner scan = new Scanner(System.in);
num = scan.nextInt();
dig = scan.nextInt();
int counter = 0;
for (counter = 0; num > dig;) {
if (num % 10 == dig); {
/** reduce  num*/
num = num / 10;
counter++;
return counter;
}
// This part is where I get the error:
public static int noOfLetters(String str){
Scanner scan = new Scanner(System.in);
str = scan.nextLine();
String letter = 0;
int[] count = new int[letter];
/** Count array with frequency of characters 
*/
int i;
for (i = 0; i < str.length(); i++)
if (str.charAt(i) != ' ')
count[(int) str.charAt(i)]++;
int n = i;
/** Prints the characters that are more than 0
*/
for (i = 0; i < n; i++)
if (count[(int) str.charAt(i)] == 1)
System.out.print(str.charAt(i));
}
}
}
}
public class Mmn15 {
public static int digInNumFor(int num, int dig) {
Scanner scan = new Scanner(System.in);
num = scan.nextInt();
dig = scan.nextInt();
int counter = 0;
for (counter = 0; num > dig;) {
if (num % 10 == dig) {
/** reduce  num*/
num = num / 10;
counter++;
return counter;
}
// Method Body ends
}
public static int noOfLetters(){
Scanner scan = new Scanner(System.in);
String str = scan.nextLine();
int letter = 26;
int[] count = new int[letter];
/** Count array with frequency of characters 
*/
int i;
for (i = 0; i < str.length(); i++)
if (str.charAt(i) != ' ')
count[str.charAt(i) - 'a']++;
int n = i;
/** Prints the characters that are more than 0
*/
for (i = 0; i < 26; i++)
if (count[(int) str.charAt(i)] >= 1)
System.out.print(str.charAt(i));
}
}
}
}

最新更新