Skip to main content

Posts

List Interface of JAVA 8

List Interface List Interface is the subinterface of Collection. It contains index-based methods to insert and delete elements. It is a factory of ListIterator interface. Lists may contain duplicate elements. The Java platform contains two general-purpose List implementations. ArrayList , which is usually the better-performing implementation, and LinkedList which offers better performance under certain circumstances. List interface includes different operations: #       Query Operations #      Modification Operations #      Bulk Modification Operations #      Comparison and hashing #      Positional Access Operations #      Search Operations #      List Iterators #      view Let’s see the List Interface from java.util pacjage: package java.util; import java.util.function.UnaryOperator; public interface List <E> extends Collection <E> {     // Query Operations     int size();   /**Returns the number of elements in this list. *
Recent posts

Iterators in java 8

An  Iterator  is an object that enables you to navigate through a collection and to remove elements from the collection selectively, if desired. You get an Iterator for a collection by calling its iterator method. The following is the Iterator interface . public interface Iterator<E> {     boolean hasNext();     E next();     void remove(); //optional } The  hasNext()  method returns  true  if the iteration has more elements, and the  next()  method returns the next element in the iteration.   The  remove()  method removes the last element that was returned by  next  from the underlying  Collection . The  remove  method may be called only once per call to  next  and throws an exception if this rule is violated. [ Note :  Iterator.remove  is the  only  safe way to modify a collection during iteration; the behavior is unspecified if the underlying collection is modified in any other way while the iteration is in progress.] Use  Iterator  instead of t

Features of Java:

Features of Java: In   Java Programming language we introduce with some keyword like Object-oriented, Simple, Portable Platform independent   etc.   Yes! These are feature of Java. There are many features in Java. They are also known as java buzzwords. The main features of Java are: Simple Object-Oriented   Portable   Platform independent     Secured     Robust   Architecture-neutral   Dynamic     Interpreted     High Performance     Multithreaded     Distributed The Java Features are given below in detail. Simple Java is easy to learn and its syntax is quite simple, clean and easy to understand. The confusing and ambiguous concepts of C++ are either left out in Java or they have been re-implemented in a cleaner way. No need to remove unreferenced objects because there is Automatic Garbage Collection in java. E.g.: Pointers and Operator Overloading are not there in java but were an important part of C++.   Object-oriented