Question:
Need help with toString method?
i messed up
2010-01-25 16:42:50 UTC
I need to write a toString method allowing me to write the time (which in my program is represented by three variables: hour, minute, and second) in the form "hh:mm:ss"

Any advice would be greatly appreciated as this is the last method i have to complete to complete the entire program.
thanks!
Three answers:
mata
2010-01-25 16:49:46 UTC
public String toString() {

return hour + ":" + minute + ":" + seconds;

}

or

public String toString() {

return String.format("%02d:%02d:02d", hour, minute, seconds);

}

if you want it in the form 01:02:03
John
2010-01-25 16:52:48 UTC
I'm glad you got an answer. I could use some help with mine thanks.

https://answersrip.com/question/index?qid=20100125164626AAa7ghO&r=w
?
2010-01-25 22:35:56 UTC
what language?


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...