mraxis M mraxis Регистрация 7 Окт 2013 Сообщения 86 Репутация 0 Спасибо 0 Монет 0 12 Ноя 2016 #1 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 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 Что не так ?
Svolo4b S Svolo4b Регистрация 13 Ноя 2013 Сообщения 70 Репутация -2 Спасибо 0 Монет 0 12 Ноя 2016 #2 i = i-1; должно выполняться в любом случае if(chr == ){ count = count + 1; } i = i-1; Позитивный голос 0