Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Java class method
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Andres
Java class method
0 Answer(s)      4 years and 10 months ago
Posted in : Java Beginners


I have created a method that's supposed to return a basetime value, returning a string value, the problem is that i need to have it return a basetime to use it later. How can i modify this code to have it returning the basetime value im looking for?
public String plus(BaseTime that) {
int totalSeconds1 = (this.hours * MINUTES_PER_HOUR +
this.minutes) * SECONDS_PER_MINUTE + this.seconds;
int totalSeconds2 = (that.hours * MINUTES_PER_HOUR +
that.minutes) * SECONDS_PER_MINUTE + that.seconds;
int result = totalSeconds1 + totalSeconds2;
int secPlus = result % SECONDS_PER_MINUTE;
int minPlus = (result / SECONDS_PER_MINUTE) % MINUTES_PER_HOUR;
int hourPlus = (result / SECONDS_PER_MINUTE) / MINUTES_PER_HOUR;
String outcome = String.format("%2d:%02d:%02d", hourPlus,
minPlus, secPlus);
return outcome;
}

Advertisement
View Answers

Related Tutorials/Questions & Answers:
class method in java
class method in java  How to write a class method in Java?   You must read Java - Class, Object and Methods in Java
Class and method question, Java?
Class and method question, Java?  Consider a Java class that you could use to get an acceptable integer value from the user. An object of this class... getValue b. implement the class in Java c. Write some Java statements that test
Advertisements
Java class method - Java Beginners
Java class method  I have created a method that's supposed to return a basetime value, returning a string value, the problem is that i need to have it return a basetime to use it later. How can i modify this code to have
Calling java class method from javascript
Calling java class method from javascript  I want to call a java class method from javascript. The java class method is like "public String[] getWord()". I want to assign this string array value to a variable in javascript. I
Example for a method in java which returns a class
Example for a method in java which returns a class  Hi, I want to create a 1 class,and declare some methods there.I need to method must returns a classname.when i call that particular method(which returns a class),how can i
clone() method of object class - Java Interview Questions
clone method of object class  Why clone() method is defined in Object class.As clone() method is inherited when Clone able Interface is implemented? Please help me in this regard. Thanks in advance
Use of getInt() method of ByteBuffer class in java.
Use of getInt() method of ByteBuffer class in java.  In this tutorial, we will see how to read integer value from byte buffer by using getInt() method of ByteBuffer class. ByteBuffer API: The java.nio.ByteBuffer class extends
Use of hashCode() method of LongBuffer class in java.
Use of hashCode() method of LongBuffer class in java. In this tutorial, we will see the use of hashCode() method of LongBuffer class in java. LongBuffer API: The java.nio.LongBuffer class extends java.nio.Buffer class
Use of hasCode method of FloatBuffer class in java.
Use of hashCode method of FloatBuffer class in java. In this tutorial, we will see the use of hashCode() method of FloatBuffer class in java. FloatBuffer API: The java.nio.FloatBuffer class extends java.nio.Buffer class
Use of getChar method of ByteBuffer Class in java.
Use of getChar method of ByteBuffer Class in java. In this tutorial, we will discuss the use of getChar() method of ByteBuffer class to fetch... of ByteBuffer class write bytes into buffer, and the getChar() method of 
Use of getFloat() method of ByteBuffer class in java.
Use of getFloat() method of ByteBuffer class in java.  In this tutorial...: The java.nio.ByteBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method Description
Use of hasArray() method of ByteBuffer class in java.
Use of hasArray() method of byte buffer class in java. In this tutorial, we... or not, and provides read/write access. ByteBuffer API. The java.nio.ByteBuffer class extends java.nio.Buffer class. It provides the following methods
Use of array() method of FloatBuffer class in java.
Use of array() method of FloatBuffer class in java.  In this tutorial, we...: The java.nio.FloatBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method Description
Use of isDirect() method of intBuffer class in java.
Use of isDirect() method of intBuffer class in java. In this tutorial, we.... The java.nio.IntBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method Description abstract boolean
Use of equals() method of  FloatBuffer class in java.
Use of equals() method of  FloatBuffer class in java.  ... or not. FloatBuffer API: The java.nio.FloatBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method
Use of equals() method of LongBuffer class in java.
Use of equals() method of LongBuffer class in java.  In this tutorial, we... API: The java.nio.LongBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method Description
Use of equals() method of IntBuffer class in java.
Use of equals() method of IntBuffer class in java.  In this tutorial, we... or not. IntBuffer API: The java.nioIntBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method Description
Use of isDirect() method of byte buffer class in java.
Use of isDirect() method of ByteBuffer class in java. In this tutorial.... The java.nio.ByteBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method Description abstract boolean
Use of equals() method of ByteBuffer class in java.
Use of equals() method of ByteBuffer class in java.  In this tutorial, we... or not. ByteBuffer API: The java.nio.ByteBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method Description
Use of getTotalIn and getTotalOut method of Inflater class in java.
Use of getTotalIn and getTotalOut method of Inflater class in java. In this tutorial, we will discuss about getTotalIn() and getTotalOut() method of Inflater... java.lang.Object class. It provid following method: Return Type Method
Use of slice method of FloatBuffer class in java.
Use of slice method of FloatBuffer class in java. In this tutorial, we will see the use of slice method of FloatBuffer class in java. FloatBuffer API: The java.nio.FloatBuffer class extends java.nio.Buffer class. It provides
Use of getTotalIn and getTotalOut method of Deflater class in java.
Use of getTotalIn and getTotalOut method of Deflater class in java...; output stream. The finish() method of Deflater class is used to indicate... and getTotalOut() method. The Defleter class create a compressor object
Use of write method of CheckedOutputStream class in java.
Use of write method of CheckedOutputStream class in java. In this tutorial, we will discuss the use of write(int b) method of CheckedOutputStream class... to use write(int b) method of CheckedOutputStream class. The FileInputStream class
ShortBuffer in java, Use of isDirect() method of ShortBuffer class in java.
Use of isDirect() method of ShortBuffer class in java. In this tutorial... API: The java.nio.ShortBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method Description
ShortBuffer in java, Use of equals() method of ShortBuffer class in java.
Use of equals() method of ShortBuffer class in java.  In this tutorial... or not. ShortBuffer API: The java.nio.ShortBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method
ShortBuffer in java, Use of slice method of ShortBuffer class.
ShortBuffer in java, Use of slice method of ShortBuffer class. In this tutorial, we will see the use of slice method of ShortBuffer class in java. ShortBuffer API: The java.nio.ShortBuffer class extends java.nio.Buffer class
ShortBuffer in java, Use of toString() method of ShortBuffer class.
Use of toString() method of ShortBuffer class. In this tutorial, we will see... API: The java.nio.ShortBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method Description
Use of getMethod, getSize and getTime method of ZipEntry class in java.
Use of getMethod, getSize and getTime method of ZipEntry class in java... method of ZipEntry class returns compression method of entry, and the getSize... of ZipEntry class ZipEntry.STORED and ZipEntry.DEFLATED.The entries() method
 Use of getBytesRead, getByteWritten and getRemaining method of Inflater class in java.
Use of getBytesRead, getByteWritten and getRemaining method of Inflater class...() and getRemaining() method of Inflater class. The Inflater class provide...: The java.util.zip.Inflater class extends java.lang.Object class. It provid following method
Abstract class and abstract method
of a concrete class. A single abstract method must exists in a abstract class. A concrete class cannot hold abstract method. An abstract class is meant... be private because it defined in the other class. An abstract methods cannot
Java method Overriding
Java method Overriding       Below example illustrates method Overriding in java. Method overriding in java means a subclass method overriding a super class method. Superclass
 

 

 

DMCA.com