I have a question about java infinite loop

Asked 2 years ago, Updated 2 years ago, 90 views

public static String solution(String new_id) {
    for(;;) {
        for(int i = 0; i < answer.length(); i++) {
                If(answer.substring(i) == ".) { // When the period is met

            } } else {
                break;
            }
        }
    }
    return answer;
}

If you write an infinite loop like this in Eclipse, the code below except return appears with a red line It says "Remove" on the quick fix.

If I use an infinite loop, can I not use the code below? Or did I write the wrong code?

java infinite-loop

2022-09-20 18:07

1 Answers

You can build even if there is a red line. Press the Run button.

and answer.substring(i) in the if statement.I think you should change it to equals (".").


2022-09-20 18:07

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.