Read all elements in vector

We can read all elements in vector by following ways: Read all elements in vector using iterator. Read all elements in vector using Enumeration. Read all elements in vector using iterator package com.w3schools;   import java.util.Iterator; import java.util.Vector;   /** * Read all elements in vector using iterator * @author w3schools */ public class ReadVectorElements … Read more

Vector class in Java

The java.util.Vector class implements a growable array of objects. Like an array, it contains components that can be accessed using an integer index. However, the size of a Vector can grow or shrink as needed to accommodate adding and removing items after the Vector has been created. It extends AbstractList and implements List interfaces. Vector … Read more

Remove element from collection

We can remove elements from java collection by following ways: Removing collection elements using Iterator Removing collection elements using Collection.removeIf() Removing collection elements using Stream filter Removing collection elements using Iterator package com.w3schools;   import java.util.ArrayList; import java.util.Iterator; import java.util.List;   /** * Removing collection elements using Iterator * @author w3schools */ public class RemoveCollectionElements … Read more

Iterate collection objects in java

We can iterate collection objects by following 4 ways: Using Classic For Loop Using Iterator Method Using Enhanced For Loop Using forEach Method with Lambda Expressions Using Classic For Loop package com.w3schools;   import java.util.ArrayList; import java.util.List;   /** * Iterate collection objects using Classic For Loop * @author w3schools */ public class IterateCollection { … Read more

Java 8 features with examples

Java Platform, Standard Edition 8 is a major feature release of Java programming language development. Its initial version was released on 18 March 2014. Here is the list of Java 8 features with examples. Java 8 features Java 8 functional interface. Java lambda expression. Java lambda expression hello world. Java lambda expression multiple parameters. Java … Read more

Java Month enum

Java Month is an enum which represents the 12 months of the year. Java Month enum methods Method Description int getValue() It is used to get the month-of-year int value int get(TemporalField field) It is used to get the value of the specified field from this month-of-year as an int. int length(boolean leapYear) It is … Read more

Java DayOfWeek enum

Java DayOfWeek is an enum representing the 7 days of the week. Java DayOfWeek class methods Method Description int get(TemporalField field) It is used to get the value of the specified field from this day-of-week as an int. boolean isSupported(TemporalField field) It is used to check if the specified field is supported. DayOfWeek minus(long days) … Read more

Java 8 Instant class

The java.time.Instant class is used to represent the specific moment on the time line Java Instant class methods Method Description Temporal adjustInto(Temporal temporal). It is used to adjust the specified temporal object to have this instant. int get(TemporalField field) It is used to get the value of the specified field from this instant as an … Read more

Java 8 Duration class

The java.time.Duration class is used to measures time in seconds and nanoseconds. Java Duration class methods Method Description Temporal addTo(Temporal temporal) It is used to add this duration to the specified temporal object. static Duration between(Temporal startInclusive, Temporal endExclusive) It is used to obtain a Duration representing the duration between two temporal objects. long get(TemporalUnit … Read more

Java Period class

The java.time.Period class is used to measures time in years, months and days. Java Period class methods Method Description Temporal addTo(Temporal temporal) It is used to add this period to the specified temporal object. long get(TemporalUnit unit) It is used to get the value of the requested unit. int getYears() It is used to get … Read more