Im reading this book called "Head First Java" by Kathy Sierra and on page 20 it says this. This is the link to the page i am on and the problem i need to work.
http://books.google.com/books?id=uIV...uffle1&f=false
this is the code i wrote.
public class Practice { public static void main(String[] args){ int x = 3; while (x > 0) { if (x > 2) { System.out.print("a"); } if (x == 2) { System.out.print("b c"); } if (x == 1) { System.out.print("d"); x = x - 1; } x = x - 1; System.out.print("-"); } } }
I am supposed to get the answer: a-b c-d
instead i get the answer: a-b c-d-
How is this?