我有關於如何計算在陣列中的字母數分配的字母數。 這裏是我的代碼:如何計算陣列中的java的
import java.util.Scanner;
public class task1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
//Create a scanner object
Scanner input = new Scanner(System.in);
//Prompt user's input
System.out.println("Enter strings (use a space to separate them; hit enter to finish) : ");
String str = input.nextLine();
// use split to divide the string into different words cutting by " "
String [] wordsArray = str.trim().split(" ");
System.out.println("The length of string is " + wordsArray.length);
for(int i = 0 ; i < wordsArray.length; i++){
char [] eachLetterinArray = wordsArray[i].toCharArray();
for(int j = 0,count = 0 ; j < eachLetterinArray.length; j++){
if( (eachLetterinArray[j]+'a'-97 >=65 && eachLetterinArray[j]+'a'-97 <=90)
|| (eachLetterinArray[j]+'a'-97 >=97 && eachLetterinArray[j]+'a'-97 <=122) ){
count++;
}
System.out.print(count);
}
}
}
,如果我輸入「結束TR」 輸出爲「12312」 ,但我要的是「3 2」
我已經嘗試了很多,仍然有對此無關...... 你能幫助我嗎?
輸出'// TODO自動生成方法stub'似乎IDE爲你生成。嘗試調試器IDE – NewUser
但我在Java中新..我不知道如何嘗試在IDE .. –
http://stackoverflow.com/questions/18977397/debug-java-program-step-by-step調試-in-eclipse – NewUser