Didn't add condition for if the lengths are equal.
Getting output if first/second is bigger than its next value, otherwise stuck and can't go ahead!
package com.codegym.task.task07.task0718;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Checking the order
1. Read 10 words from the keyboard and add them to a list of strings.
2. Determine whether the list is ordered by increasing string length.
3. If it is not, then display the index of the first element that violates this order.
*/
public class Solution {
public static void main(String[] args) throws IOException {
//write your code here
boolean isConditionMet = false;
String str = new String();
ArrayList<String> arr_li = new ArrayList<String>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for(int i = 0; i < 10; i++) {
str = reader.readLine();
arr_li.add(str);
}
for(int i = 0; i < 10; i++) {
for(int j = 1; j < 10; j++) {
if(arr_li.get(i).length() > arr_li.get(j).length()) {
System.out.println(arr_li.get(i));
isConditionMet = true;
break;
}
if(isConditionMet)
break;
}
if(isConditionMet)
break;
}
/*
for(String a : arr_li)
for(String b : arr_li)
*/
}
}
//Rest don't know, see later!