Just to understand, what is happening I done the below code:
public class Loopp {
public static void main(String[] args) {
int i=1;
while(true) {
Employee e = new Employee("MyName", i);
i++;
System.out.print(i + " ");
}
}
}
But on console I do not see any output, but when I run this in debug mode, then it prints 2 3 4 ..
I understand that gc is activated again and again to collected the garbage objects, but does that clear console also :|
Edit:
As per the answer , it worked for me, and I learned a new thing today
System.out.println(i + " ");
System.out.flush();