Found 9326 Articles for Object Oriented Programming

Create Septet Tuple from another collection in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

64 Views

The fromCollection() method is used in JavaTuples to create Septet Tuple from another collection. We will see an example of creating a Septet Tuple using List collection.Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import the following package −import org.javatuples.Septet;Note − Steps to download and run JavaTuples program. If you are using Eclipse IDE to run Septet Class in JavaTuples, then Right Click Project ->Properties ->Java Build Path ->Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Septet; import java.util.*; public ... Read More

Create Unit Tuple from List in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

83 Views

To create Unit Tuple from another collection, use the fromCollection() method. Here, we will create a Unit Tuple from a List collection, therefore the same method is used.Let us first see what we need to work with JavaTuples. To work with JavaTuples. To work with the Unit class in JavaTuples, you need to import the following package −import org.javatuples.Unit;Note − Steps to download and run JavaTuples program. If you are using Eclipse IDE to run Unit Class in Java Tuples, then Right Click Project ->Properties ->Java Build Path ->Add External Jars and upload the downloaded JavaTuples jar file.The following is ... Read More

Duration plusNanos() method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

51 Views

An immutable copy of a duration where some nanoseconds are added to it can be obtained using the plusNanos() method in the Duration class in Java. This method requires a single parameter i.e. the number of nanoseconds to be added and it returns the duration with the added nanoseconds.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class Demo { public static void main(String[] args) { Duration d = Duration.ofSeconds(1); System.out.println("The duration is: " + d); ... Read More

Duration plusDays() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

90 Views

An immutable copy of a duration where some days are added to it can be obtained using the plusDays() method in the Duration class in Java. This method requires a single parameter i.e. the number of days to be added and it returns the duration with the added days.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class Demo { public static void main(String[] args) { Duration d = Duration.ofDays(5); System.out.println("The duration is: " + d); ... Read More

Duration minusNanos() method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

41 Views

An immutable copy of a duration where some nanoseconds are removed from it can be obtained using the minusNanos() method in the Duration class in Java. This method requires a single parameter i.e. the number of nanoseconds to be subtracted and it returns the duration with the subtracted nanoseconds.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class Demo { public static void main(String[] args) { Duration d = Duration.ofSeconds(1); System.out.println("The duration is: " + d); ... Read More

Duration minusMillis() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

62 Views

An immutable copy of a duration where some milliseconds are removed from it can be obtained using the minusMillis() method in the Duration class in Java. This method requires a single parameter i.e. the number of milliseconds to be subtracted and it returns the duration with the subtracted milliseconds.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class Demo { public static void main(String[] args) { Duration d = Duration.ofSeconds(1); System.out.println("The duration is: " + d); ... Read More

Duration withNanos() method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

72 Views

The immutable copy of a duration with the required nanoseconds is obtained using the method withNanos() in the Duration class in Java. This method requires a single parameter i.e. the number of nanoseconds and it returns the duration with the required nanoseconds that were passed as a parameter.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class Demo { public static void main(String[] args) { int nanoseconds = 1000000; Duration duration = Duration.ofHours(10); System.out.println("The duration ... Read More

Duration of() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

142 Views

The required duration using a particular temporal unit can be calculated with the method of() in the Duration class in Java. This method requires two parameters i.e. the time value and the temporal unit for that value. It returns the time duration with the particular value and temporal unit.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.*; public class Demo {    public static void main(String[] args) {       long timeValue = 2;     Duration d = Duration.of(timeValue, ChronoUnit.HOURS); System.out.println("The duration in minutes is: ... Read More

Duration minusMinutes() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

71 Views

An immutable copy of a duration where some minutes are removed from it can be obtained using the minusMinutes() method in the Duration class in Java. This method requires a single parameter i.e. the number of minutes to be subtracted and it returns the duration with the subtracted minutes.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class Demo { public static void main(String[] args) { Duration d = Duration.ofMinutes(60); System.out.println("The duration is: " + d); ... Read More

Duration minusSeconds() method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

80 Views

An immutable copy of a duration where some seconds are removed from it can be obtained using the minusSeconds() method in the Duration class in Java. This method requires a single parameter i.e. the number of seconds to be subtracted and it returns the duration with the subtracted seconds.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class Demo { public static void main(String[] args) { Duration d = Duration.ofMinutes(1); System.out.println("The duration is: " + d); ... Read More

Advertisements