Próbowałem kilkanaście razy, z początku wyświetlałem list.get(i) ale wtedy wyświetli mi ciąg, a nie index. Myślę, że dobrze to zrozumiałem. poprawiłem i dalej nie wiem jak wyświetlić numer indexu.
I tried a dozen times, at first I displayed list.get (i) but then it will display a string to me, not index. I think I understood it well. Corrected it and still don't know how to display the index number.
package pl.codegym.task.task07.task0718;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Sprawdzanie kolejności
*/
public class Solution {
public static void main(String[] args) throws IOException {
//tutaj wpisz swój kod
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
list.add(reader.readLine());
}
int index = 0; //zlicza index
for (int i = 0; i < list.size()-1; i++) {
if (list.get(i).length() < list.get(i+1).length()) {
// nic nie wyświetlaj
index = + 1;
}
else System.out.println(index);
break;
}
}
}