我有关于如何计算在阵列中的字母数分配的字母数。 这里是我的代码:如何计算阵列中的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