JDK prepares to use pattern matching in future versions. In JDK 12 pattern matching has been implemented in switch expression. And the same is being implemented to instanceOf in JDK 14 as a preview feature. In java program, instanceof include logic that combines testing if an expression has a certain type, and then conditionally extracting… Continue reading
Posts in "Core Java"
Java for loop
Java for loop and enhanced for loop is a type of control flow statement which provides a compact way to iterate over a range of values. for loop repeatedly loops through the code until a particular condition is satisfied. Over the period, Java has added different types of for loop. for loop Enhanced for loop… Continue reading
Switch case statement in Java
A switch statement is a conditional statement that tests against multiple cases and displays one or multiple outputs based on the matching circumstances. Unlike if-then and if-then-else statements, the switch statement can work with byte, short, char, and int primitive data types. It also works with enum types (discussed in Java Enum), the String class, and a few wrapper classes: Character, Byte, Short, and Integer. Important Rules Only constants or literals are allowed in case Duplicate… Continue reading
Data types in Java
Java is a statically-typed language, which means that all variables must first be declared before they can be used. It means the variable’s name and types must be defined before it can be used in code. boolean bool = true; By writing the above line we are telling the program that a variable named bool… Continue reading
Java method parameter and argument
In this article, we will talk about the method parameter and method argument. Please make a note that the method argument and method parameter are sometimes used interchangeably. Parameters refer to the list of variables in a method declaration. Arguments are the actual values that are passed in when the method is invoked. When you invoke a method, the… Continue reading
Java 8 Functional Interfaces
Introduction to functional interfaces A functional interface is an interface that has a single abstract method. Functional interfaces can have multiple static and default methods, but they should have only one abstract method to qualify as a functional interface. Functional interfaces were introduced in Java 8 in order to implement lambda expressions.
History of java
Java is a general, all-purpose computer programming language that is circumstantial, class-based, object-oriented, and specially designed to have few application dependencies as possible. Java was developed initially for interactive television, but it was too advanced technology for the digital cable television industry at the time. It is proposed to let application developers “write once, run… Continue reading
Different ways to create an object in Java
You must be aware of creating an object of a class by using the new keyword, but that is not the only way to create an Object. There are several other ways to create an object of a class : Using new keyword Using new Instance (Reflection) Using Clone Using Deserialization Using ClassLoader … don’t… Continue reading
Java Class & Object Tutorial for beginners
A class is a template for creating objects which define their state and behavior. A class contains a field and method to define the state and behavior of its object.
Java Collection Iterators
With this article we will kick-off a new series where we will look deep into Java’s different collection solutions which are available in the version 1.8. For concrete implementations (like ArrayList or TreeSet) we will give you some use-cases where these collections will excel and some cases where you should use different collections. And of… Continue reading