0
what is the problem here??
import java.util.Scanner; class Count_ch { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("enter the string: "); String str = sc.nextLine(); int letter =0; int digit =0; int space = 0; for(int i = 0;i<=str.length();i++) { if(Character.isLetter(str.charAt(i))) { letter++; } if(Character.isDigit(str.charAt(i))) { digit++; } if(Character.isSpaceChar(str.charAt(i))) { space++; } } System.out.println("Letters: " + letter + "\n" + "Digit: " + digit + "\n" + "space: " + space ); } }
1 Answer
+ 5
shashisingh singh
i < str.length()