Why is my code not correct? I tried this in eclipse and it outputs correctly.