What is the code doing exactly and what is the theoretical reason why this code is not compiling? (part 4)

Please see below some java code which I am trying to compile and run. I am fully aware that the code has an error. I also know how to fix it (as you can see from the comment I added just below: while (true){). What I don't however know is what this code is actually doing. Is it looping infinitely? Does it stop abruptly? What is the exact reason behind why I get a compile error (Unable to execute program; could not compile!)?

I am thinking, if the while condition is not met because it is false, should the code not ignore the while block and jump to the next line of code outside the while block - 'System.out.println("out of loop");' - and run it once and then stop?

import java.util.Random;

public class PartA {

        //loop until i is equal to j
		private static void loop6(){
			Random r = new Random();
			int i = 0;
			int j = 10;
			while (false){
          	        //while (true){
				i = r.nextInt(10);
				j = r.nextInt(1000);
				System.out.println("i = "+i+" and j = "+j);
				if (i==j)break;
			System.out.println("out of loop");

        private static void runLoops() {

	public static void main(String[] args) {


Open in new window

thanks in advance
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

A 'while(){}' construct only runs if its conditional argument is true.
You could run it with this though if you really need to :

while (!(true)==false){

Open in new window


Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.