Hi friends,
For my homework I must try to guess the possible output but its very difficult.
This is the code
package mix5; public class Mix5 { int counter = 0; public static void main(String[] args) { int count = 0; Mix5[] m5a = new Mix5[20]; int x = 0; while ( x < 9) { m5a [x] = new Mix5(); m5a[x].counter = m5a[x].counter + 1; count = count + 1; count = count + m5a [x].maybeNew(x); x = x + 1; } System.out.println( count + " " + m5a [1].counter); } public int maybeNew (int index) { if (index < 5 ){ Mix5 m5 = new Mix5(); m5.counter = m5.counter + 1; return 1; } return 0; } }
The output is "14 1"
But how create eclipse this output? I tried and tried but it's not working for me. Can anybody explain this output?
(Head First Java pg 90)
Thanks
Regards Manzara