Your condition would be i!=3
. Change to while(i!=3)
. You have mistakenly put the wrong condition in the while loop. You have said it to loop the while only when i==3
otherwise to exit the loop. So you need to change it to
do {
System.out.println(i);
i++;
} while (i!=3);
Hope this clarifies!