JAVA basis (infinite loop)

1, two of the most simple infinite loop format

  • Infinite loop while statement

        while (true) {

            System.out.println("hello world");

        }
  • Infinite loop for statement

    

    for (; ; ) {

            System.out.println("hello world");

        }

2 Notes

  • We must pay attention to control problems that variable control of conditional statements, do not lose it, otherwise it is easy endless loop.

 

 

Guess you like

Origin blog.csdn.net/Cricket_7/article/details/90671648