Java 8 Lambda Expression

As java is an object oriented language and everything in java are objects, except primitive types. We need object references to call any method. But what in case of Java script. We can define functions anywhere we want, can assign functions to any variables, and can pass functions as an input parameters to a method. … Read more

Java 8 Functional Interface

Java 8 Functional Interface Functional Interface is an interface with only single abstract method. As a functional interface can have only one abstract method that’s why it is also known as Single Abstract Method Interfaces or SAM Interfaces. We can either create our own functional interface or can use predefined functional interfaces provided by java. … Read more

Java 7 Features with Examples

Java 7 String In Switch Case Statement Java switch statement: Java switch statement is used to execute a block of statement based on the switch expression value. It is like if else if statement.… Read More Java 7 Try With Resources Example Resource: A resource is an object that must be closed after the program is … Read more

java 7 catch multiple exceptions

Java 7 provides the facility to catch multiple type exceptions in a single catch block to optimize code. We can use vertical bar or pipe (|) to separate multiple exceptions in catch block. Multiple exceptions handling before Java 7 package com.w3schools; public class MultipleExceptionHandling { public static void main(String args[]){ try{ int array[] = new … Read more

Java 7 Numeric Literals with Underscore

Numeric Literals Java 7 provides the facility to use underscore in numeric literals like int, byte, short, float, long, double. We can use any number of underscore characters (_) between digits in a numerical literal. It helps to improve the code readability. Note: Underscores cannot be put at the end of literal. So 12_ is … Read more

java 7 binary literals example

Binary Literals In Java 7, the integral types (byte, short, int, and long) can also be expressed using the binary number system. To specify a binary literal, add the prefix 0b or 0B to the number. Java binary literals example package com.w3schools; public class Java7BinaryLiterals { public static void main(String args[]){ int i=0b01111; byte b=(byte) … Read more

java 7 try with resources example

Resource: A resource is an object that must be closed after the program is finished with it. For example a File resource or JDBC resource for database connection. The try-with-resources statement: Main concept behind the try-with-resources statement is auto resource management. Before Java 7, there was no auto resource management and we explicitly have to … Read more

Java 7 String in Switch Case Statement

Java switch statement: Java switch statement is used to execute a block of statement based on the switch expression value. It is like if else if statement. Java 7 allows us to use string objects in the expression of switch statement. Note: Java switch case String is case sensitive. Java switch case uses String.equals() method … Read more

java varargs variable arguments example

Java varargs provides the facility to a method to accept variable number of arguments. Varargs refers to variable-length arguments. A variable-length argument is specified by three dots (…) also known as ellipsis. Before varargs, variable-length arguments handled either by using method overloading or take an array as the method parameter but it was not considered … Read more

java regex pattern validate html tag

Regular expression html tag pattern <("[^"]*"|'[^’]*’|[^’">])*><("[^"]*"|'[^']*'|[^'">])*> This regular expression refers to a pattern which start with an opening tag “