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



Home Answers Viewqa Java-Beginners Java class method

Have Programming Question? Ask it here!
 
 
 


Andres
Java class method
0 Answer(s)      4 years and 5 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 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  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 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
Java class in JSP
Java class in JSP          To use a Java class method in jsp first we need... the method defined inside the java class.  The code of the program is given
Method Overriding in Java
Method Overriding in Java means a Subclass uses extends keyword to override a super class method. In Overriding both subclass and superclass must have same parameters. Method Overriding in Java is used so that a subclass can implement
java method
java method  can we declare a method in java like this static { System.loadLibrary("nativelib"); } i have seen this in a java learning E book. i don't understand the static { } plz help me. what kind of method
Use of rewind() method of FloatBuffer class.
Use of rewind() method in float buffer class. In this tutorial, we will see the Use of rewind method of FloatBuffer class. FloatBuffer API: The java.nio.FloatBuffer class extends java.nio.Buffer class. It provides the following
Java call method from another class
Java call method from another class   ...; methods of another class. For this we have created two java files..., multiply, division and modulus have been created inside the class CallingMethod
Use of putChar() method of ByteBuffer class.
Use of putChar() method of ByteBuffer class.  In this tutorial, we...: The java.nio.ByteBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method Description
Use of toString() method of FloatBuffer class.
Use of toString() method of FloatBuffer class. In this tutorial, we will see...: The java.nio.FloatBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method Description
javascript call action class method instruts
javascript call action class method instruts  in struts2 onchange event call a method in Actionclass with selected value as parameter how can i do
Java class
Java class  What is the purpose of the Runtime class
Java - Class, Object and Methods in Java
Java - Class, Object and Methods in Java       Class : Whatever we can see in this world all... group. That group is termed as a class. All the objects are direct interacted
Abstract Class in Java
Abstract class in Java is a class that is declared using abstract keyword... to define an abstract method under class then we have to make the class..., the abstract method of abstract class must be defined in the subclass. Points
java class
java class  write a java program to display a msg "window closing" when the user attempts to close the window.(a) create a window class (b) create frame within the window class (c) extends window adapter class to display the msg
java class
java class  please send me the answer of the question which i have send according of java class assoon as possible . Write a java program to display.... a. Create a window class. b. Create frame within the window class. c. Extend
How to call the run method from another class?
How to call the run method from another class?  Sorry, if this is a stupid question. I would like to find out how to call the run method... run() { new FereastraPrincipala().setVisible(true); from the class
Use of hasRemaining() method in float buffer class.
Use of hasRemaining() method in float buffer class. In this tutorial, we will see the use of  hasRemaining method of Buffer class in FloatBuffer. FloatBuffer API: The java.nio.FloatBuffer class extends java.nio.Buffer class
Example of skip() method of CheckedInputStream class.
Example of skip() method of CheckedInputStream class. In this tutorial, we will discuss the use of skip() method of CheckedInputStream class. ...() method of CheckedInputStream class. The CheckedInputStream class creates a input
Use of putDouble() and getDouble() method of ByteBuffer class.
Use of putDouble() and getDouble() method of ByteBuffer class.  .... ByteBuffer API: The java.nio.ByteBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method
Java divide method example
Java divide method example       In this example Java bigdecimal class divide (BigDecimal divisor, MathContext mc) method working is demonstrated. This method divides
java method - Java Beginners
java method  Plz help me on toString() in java  Hi Friend, The Object class provides the method toString() that returns the string..., the toString() method of the object is automatically called. Thanks
 

 

 

DMCA.com