I'm very sorry to have asked such a basic question but I just cant understand how this output is generated.If someone has time to answer my dumb question,it will be very much appreciated.Thanks in advance.
this is the code
public class EchoTestDrive { public static void main(String[] args) { Echo e1= new Echo(); Echo e2= new Echo(); int x=0; while(x < 4) { e1.hello(); e1.count=e1.count +1; if(x==3) { e2.count=e2.count+1; } if(x>0) { e2.count=e2.count+e1.count; } x=x+1; } System.outprintln(e2.count); } } class Echo { int count =0; void hello() { System.outprintln("helloo..."); } } This gives the output:
helloo... helloo... helloo... helloo... 10 now to get 24 instead of 10 we declare Echo e2=e1; instead of Echo e2=new Echo; I want to know how does this generate this particular output.for 10 i can literally put values in each and get that answer but what happens when i make them equal(that i cant understand).
