- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4336 Articles for Java 8
91 Views
The number of months for a particular Period can be obtained using the getMonths() method in the Period class in Java. This method requires no parameters and it returns the number of months in the Period.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p = Period.parse(period); System.out.println("The Period is: " + p); System.out.println("The number of months are: " + p.getMonths()); } }OutputThe Period is: P5Y7M15D The number of ... Read More
283 Views
The number of days for a particular Period can be obtained using the getDays() method in the Period class in Java. This method requires no parameters and it returns the number of days in the Period.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p = Period.parse(period); System.out.println("The Period is: " + p); System.out.println("The number of days are: " + p.getDays()); } } OutputThe Period is: P5Y7M15D The ... Read More
99 Views
The hash code value of the Period can be obtained using the hashCode() method in the Period class in Java. This method requires no parameters and it returns the hash code value of the Period.A program that demonstrates this is given as follows:Example Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p = Period.parse(period); System.out.println("The Period is: " + p); System.out.println("The hash code is: " + p.hashCode()); } }OutputThe Period is: P5Y7M15D The hash code is: 984837Now ... Read More
103 Views
An immutable copy of the Period object where some years are subtracted from it can be obtained using the minusYears() method in the Period class in Java. This method requires a single parameter i.e. the number of years to be subtracted and it returns the Period object with the subtracted years.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p1 = Period.parse(period); System.out.println("The Period is: " + p1); Period p2 ... Read More
96 Views
An immutable copy of the Period object where some months are subtracted from it can be obtained using the minusMonths() method in the Period class in Java. This method requires a single parameter i.e. the number of months to be subtracted and it returns the Period object with the subtracted months.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p1 = Period.parse(period); System.out.println("The Period is: " + p1); Period p2 ... Read More
105 Views
An immutable copy of the Period object where some days are subtracted from it can be obtained using the minusDays() method in the Period class in Java. This method requires a single parameter i.e. the number of days to be subtracted and it returns the Period object with the subtracted days.A program that demonstrates this is given as follows:Example Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p1 = Period.parse(period); System.out.println("The Period is: " + p1); Period p2 ... Read More
93 Views
An immutable copy of the Period object where some years are added to it can be obtained using the plusYears() method in the Period class in Java. This method requires a single parameter i.e. the number of years to be added and it returns the Period object with the added years.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p1 = Period.parse(period); System.out.println("The Period is: " + p1); Period p2 ... Read More
171 Views
The max() method of the DoubleStream class returns an OptionalDouble describing the maximum element of this stream, or an empty OptionalDouble if this stream is empty.The syntax is as follows.OptionalDouble max()Here, OptionalDouble is a container object which may or may not contain a double value.To use the DoubleStream class in Java, import the following package.import java.util.stream.DoubleStream;Create a DoubleStream and add some elements.DoubleStream doubleStream = DoubleStream.of(67.9, 89.9, 10.5, 95.8, 49.6);Now, get the maximum element from the stream.OptionalDouble res = doubleStream.max();The following is an example to implement DoubleStream max() method in Java.Example Live Demoimport java.util.OptionalDouble; import java.util.stream.DoubleStream; public class Demo { public ... Read More
100 Views
An immutable copy of the Period object where some months are added to it can be obtained using the plusMonths() method in the Period class in Java. This method requires a single parameter i.e. the number of months to be added and it returns the Period object with the added months.A program that demonstrates this is given as follows:Example Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p1 = Period.parse(period); System.out.println("The Period is: " + p1); Period p2 ... Read More
70 Views
Use the contains() method to search for a value in the KeyValue tuple. Let us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package.import org.javatuples.KeyValue;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 implement the contains() ... Read More