Found 9326 Articles for Object Oriented Programming

LocalDate minusYears() Method in Java

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

558 Views

An immutable copy of the LocalDate where the years are subtracted from it can be obtained using the minusYears() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of years to be subtracted and it returns the instant with the subtracted years.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalDate ld1 = LocalDate.parse("2019-02-14");       System.out.println("The LocalDate is: " + ld1);       LocalDate ld2 = ld1.minusYears(2);       System.out.println("The LocalDate after subtracting ... Read More

Create Decade Tuple from a List collection in Java

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

68 Views

Use the fromCollection() method to create a Decade tuple from a List collection in Java. Let us first see what we need to work with JavaTuples. To work with Decade class in JavaTuples, you need to import the following package.import org.javatuples.Decade;Note Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples.Steps: How to run JavaTuples program in EclipseThe following is an example to create ... Read More

What is the addAtX() method of the Ennead Tuple in Java

Smita Kapse
Updated on 30-Jul-2019 22:30:25

54 Views

To add value in Ennead class in JavaTuples, you need to use the addAtX() method. Here, X represents the index wherein you need to add the value i.e. for index 2, use addAt2() method. Add the specific value as the parameter value of the method. For example −addAt2(“John”);Let us first see what we need to work with JavaTuples. To work with Ennead class in JavaTuples, you need to import the following package −import org.javatuples.Ennead;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> ... Read More

LongStream builder() method in Java

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

80 Views

The LongStream builder() class in Java is used to return a builder for a LongStream.The syntax is as follows.static LongStream.Builder builder()Here, LongStream.Builder is a mutable builder for a LongStream.To use the LongStream class in Java, import the following package.import java.util.stream.LongStream;The following is an example to implement LongStream builder() method in Java.Example Live Demoimport java.util.stream.LongStream; public class Demo {    public static void main(String[] args) {       LongStream longStream = LongStream.builder().add(5).build();       longStream.forEach(System.out::println);    } }Output5

The contains() method of the Java Ennead Tuple

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

54 Views

The contains() method of the Ennead Tuple in Java is used to search for a value in the Tuple. To find the existence of a value, you need to just set it as a parameter of the method. It returns a boolean value i.e. TRUE is returned for the existence of a value, else FALSE.Let us first see what we need to work with JavaTuples. To work with Ennead class in JavaTuples, you need to import the following package −import org.javatuples.Ennead;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project ... Read More

How to search for a value in Java Ennead Tuple

Anvi Jain
Updated on 30-Jul-2019 22:30:25

53 Views

To search for a value in Ennead Tuple in Java, use the contains() method. The value you want to search is to be set as the parameter of the method. The contains() method returns a Boolean value i.e TRUE if the value exist, else FALSE. Let us first see what we need to work with JavaTuples. To work with Ennead class in JavaTuples, you need to import the following package −import org.javatuples.Ennead;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External ... Read More

The setAtX() method of the Octet Tuple in Java

Smita Kapse
Updated on 30-Jul-2019 22:30:25

75 Views

The setAtX() method is used to set Octet value in Java. Here, X is the index wherein you need to set the value i.e. to set value at index 1, use the setAt1() and value as a parameter.Let us first see what we need to work with JavaTuples. To work with Octet class in JavaTuples, you need to import the following package −import org.javatuples.Octet;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. ... Read More

Iterate through Octet Tuple in Java

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

80 Views

You can easily iterate through Octet Tuple using a for the loop. Let us first see what we need to work with JavaTuples. To work with Octet class in JavaTuples, you need to import the following package −import org.javatuples.Octet;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples −Steps − How to run JavaTuples program in EclipseThe following is an example to ... Read More

The contains() method of the Java Octet Tuple

Anvi Jain
Updated on 30-Jul-2019 22:30:25

57 Views

If you want to search whether a particular value exist in the Java Octet Tuple, you need to use the contains() method.For example, to find the element “Motherboard”, use it like this −boolean res = oc.contains("Motherboard");As shown above, we have used boolean i.e. the contains() method returns a boolean value; TRUE if the element is in the Tuple, else FALSE.Let us first see what we need to work with JavaTuples. To work with Octet class in JavaTuples, you need to import the following package −import org.javatuples.Octet;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse ... Read More

Search for a value in Java Octet Tuple

Smita Kapse
Updated on 30-Jul-2019 22:30:25

60 Views

To search for a value in Java Octet Tuple, you need to use the contains() method. The method returns a Boolean value stating whether the element set as a parameter exists in the values set in Octet Tuple or not. Let us first see what we need to work with JavaTuples. To work with Octet class in JavaTuples, you need to import the following package −import org.javatuples.Octet;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded ... Read More

Advertisements