Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Strange. Why is that I wonder?i am not allowed to use it
What else is not allowed?
Can you build a String using concatenation(using + operator) and return that in the toString method?
If you don't understand my answer, don't ignore it, ask a question.
but now how can i dispose the part that i dont need so the out put will bepublic String toString() { final StringBuilder sb = new StringBuilder ("Time1{"); sb.append ("_hour=").append (_hour); sb.append (", _minute=").append (_minute); sb.append ('}'); return sb.toString (); }
1. Testing Constructors and toString: t1=17:45 t2=00:00
What is it you want to disposed of?how can i dispose the part that i dont need so the out put will be
Why not build the exact String you want so nothing has to be removed or changed?
Again I can not see what you are seeing so I need you to paste it here so I can see what you are talking about.
If you don't understand my answer, don't ignore it, ask a question.
Do you have the equation for that? Can you code that equation in the method and return its results?if the time stored inside the object is 07:30 than a value of 450 will be returned
If you don't understand my answer, don't ignore it, ask a question.
Do you know any algebra? Can you write a simple formula to compute the needed value?
Expressions in java use standard math symbols: +, -,*, / for add, subtract, multiply, divide
Take a look at the tutorial: https://docs.oracle.com/javase/tutor...bolts/op1.html
How did you get the value of 450?
If you don't understand my answer, don't ignore it, ask a question.
Ok, that looks like an equation.
Now replace the 7 and 30 with the variable names from the class and assign the results to a variable.
If you don't understand my answer, don't ignore it, ask a question.
Did you try it? What happened? What value was returned? Print it out to see.
If you don't understand my answer, don't ignore it, ask a question.
What is 470? What were the values of hour and minutes used in the computation?
Is that the correct answer?
Also posted at: https://www.dreamincode.net/forums/t...&#entry2416145
Please read: http://www.javaprogrammingforums.com...s-posting.html
and https://coderanch.com/wiki/660346/Wi...-Posting-Sites
If you don't understand my answer, don't ignore it, ask a question.