-2

I am just starting to learn java and i have a problem that seems to have a simple answer...

System.out.print("Your time in hours/minutes/seconds is: "); System.out.print(+hours); System.out.print(":"); System.out.print(+minutes); System.out.print(":"); System.out.print(+seconds);

How can i get the final product in one line of code without getting a compilation error? I have tried

System.out.println("Your time in hours/minutes/seconds is: " +hours ":" +minutes ":" +seconds ":");

1 Answers1

1

You're missing some concatenation + operators. Do this:

System.out.println("Your time in hours/minutes/seconds is: " + hours + ":" + minutes + ":" + seconds + ":");
gknicker
  • 5,509
  • 2
  • 25
  • 41