public class Vigen {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("Enter string ");
String s = sc.nextLine();
int count = 1;
int i = s.length();
char[] chr = s.toCharArray();
while(i>0) {
if(chr == ){
count = count + 1;
i = i-1;
}
else{
count = 0;
}
}
System.out.println("The number of words "+count);
}
}
Выкидывает исключение outofbounds
Что не так ?
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("Enter string ");
String s = sc.nextLine();
int count = 1;
int i = s.length();
char[] chr = s.toCharArray();
while(i>0) {
if(chr == ){
count = count + 1;
i = i-1;
}
else{
count = 0;
}
}
System.out.println("The number of words "+count);
}
}
Выкидывает исключение outofbounds
Что не так ?