N
N
Nikita Badyl2016-05-08 22:22:45
Java
Nikita Badyl, 2016-05-08 22:22:45

How to organize the input of lines from the console until the word end is found in some line?

An array of strings is declared.
Please tell me how to organize the input from the console lines to a certain word. So that the rest of the lines are filled with numbers = line number.?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sanan Yuzb, 2016-05-08
@nibbit

static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        while (true) {
            String S = sc.nextLine();
            if(S.equals("end")) {
                break;
            }
        }
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question