Concurrent Collection in Java

Concurrent Collection In Synchronized Collection a thread lock the entire list. Only one thread access the entire list at a time. In concurrent collection a threat lock one element, each  element can be accessed by different thread concurrently  Java supported multithreading and concurrency from initiation. Java has introduced the concurrent collection in java 5.0 and java 6.0 over the synchronized collection to improve the performance in a multithreading environment. java has provided concurrent collection API apart from collection API to handle the multithreading and concurrency in a better manner. We can find all the new concurrent collection Interfaces and Classes under the package name java.util.concurrent. In this article, we will focus on some Key interfaces and classes of the java.util.concurrent package. Synchronized Collection V/S Concurrent Collection: Synchronized Collection: Synchronized Collections are slow in performance  Multiple threads can access a synchronized coll

Artificial Intelligence Vs Machine Learning Vs Deep Learning

AI vs ML vs DL We are surrounded by multiple technologies. Artificial Intelligence, Machine Learning, Deep Learning, Data Science are common terms nowadays.  People use these terms interchangeably but all these terms are different in terms of definition, application, and limitations.  Nowadays we use many applications that are used in AI. There are many industries that work with AI like Healthcare, E-Commerce, Entertainment, Gaming, Automobile, Education, etc.  Machine Learning and deep learning are used to solve a complex task with huge datasets to make them simple. Artificial intelligence: Artificial Intelligence is a field to make a machine intelligent. AI makes machines to act like human's brains. AI incorporates human intelligence into machines. Intelligence means machines can predict, classify, reason, plan, and perceive like humans. Applications      Self-driving cars like Tesla, Nissan,  Voice Assistants like Siri and Alexa, Amazon Echo Machine Learning It is a subset of AI

Java 8 Vs Java 9

Java 8 Features 1. forEach() forEach(): method is used to iterate the elements. It takes a single parameter. It is a default method of the Iterable interface. We can pass lambda expressions as an argument. public class ForEachExample {     public static void main(String[] args) {         List<String> list = new ArrayList<String>();         list.add("One");         list.add("Two);         list.add("Three");         list.add("Four");         list.forEach(li -> System.out.println(li));     } } 2. Functional Interfaces and Lambda Expressions Functional Interface The Functional interface contains only one abstract method and also contains a number of default and static methods. Functional Interface is annotated by @FunctionalInterface annotation, it ensures that the interface contains only one abstract method. Some predefined functional interfaces are: Runnable, Comparable, and ActionListener.  Lambda Expression Lambda expressions pr

Default Methods in Interface - Java 8

Java interfaces use to have only abstract methods thanks to JDK 8 which allows the interface to add default and static methods. During the application enhancement or maintenance, it may possible that new methods are required to be added in an interface that forced all implemented classes to be changed and implement new abstract methods. Thus we can add these default methods to existing interfaces without breaking the code and changing old implementation classes. interface DefaultMethod {  public default void defMethod(){    System.out.println("Default Method");  } } public class TestDefault implements DefaultMethod{   public static void main(String[] args) {     TestDefault t = new TestDefault();      t.defMethod();    } } Likewise, you can define  default static methods  in an interface with the restriction of not overriding static methods.

Data Science and Employment Opportunities

Data Science Data  As we all know the world is rapidly growing in the field of Information Technology and we have to store lots of information in the form of data, that a large amount of data is known as Big Data .  The challenge which comes with big data is storage and access to the right information out of bulk data for business analysis and predictions. Before this era the data was less and stored in a structured manner, nowadays the data is huge and can be structured, unstructured, and semi-structured. Structured, Unstructured, Semi-structured huge data  Cleaning, Processing, Maintaining, Organizing The solution which comes to store the big data is Hadoop and other frameworks, now the main attraction is cleaning, processing, maintaining, organizing and analyzing that data, here the Data Science comes in the role. In short Data Science is extracting meaningful data or information from large and complex datasets. Cleaning, Processing, Maintaining, Organizing Data Analysis, and Machin

Lambda Expressions

Lambda expressions provide the simplest and shortest way to define anonymous functions.  Java Swing frequently uses anonymous functions for event handling. Lambda expressions define the body of Functional Interfaces . An interface that has only one abstract method, is called Functional Interface. It can be annotated by  @FunctionalInterface annotation. Let's define HelloInt functional interface that has an abstract method  say()  : @FunctionalInterface interface HelloInt { public void say(); } Now define interface definition using old anonymous function approach:  HelloInt aFun = new HelloInt() { public void say() { System.out.println("Hello Anonymous Function"); } }; aFun.say(); Let's define the anonymous function using Lambda expression:   HelloInt lambFun = () -> System.out.println("Hello Lambda"); lambFun.say(); The above example, clearly shown the shortest code of an anonymous function definition. The only condition is interface must have

Java Streams API - Process set of elements

A Stream is a series of objects. Source of a stream is an Array, Collection, or Other I/O source. A Stream does not store data, it does only intermediate operations. It can filter and manipulate the elements of its source. Streams are lazy, the source and intermediate operations do nothing until objects are needed by the terminal operation. Steams APIs are contained by package.  A water filter is the best example of streams.   It processes the water stream.  It has multiple filters that work one after another.  Filters do purification, reverse osmosis, refinement of water, and produce drinking water.  The water filter does not store the water it simply processes the water stream. Getting Started  1. Create a Stream and print all elements  Let's create a stream from a collection and print all its elements.  The following example creates a Stream from the list collection and prints all elements of the collection using its forEach method. List<String> items =