Java SE 8 features

Java SE 8 Features Some of the important Java se 8 features are Please click on each link for detailed explanation lambda expressions functional interface foreach method in java.lang.iterable Default methods and Static methods Method References Remaining features will be updated soon ………

Continue reading

Generics

Generics Java Generics features were introduced from Java Se 5 onwards. Before Java 5, we can store any type of objects in collection i.e. non generic. With inclusion of Generics we need to store only specific type of objects only. Let’s look at the benefits of generics Compile time checking: Generics allows you to check…

Continue reading

Custom Annotation

Custom Annotation Similar to interface we can define Custom Annotations or user defined annotations simply by adding @interface in the declaration. For example: @interface CustomAnnotation{} Here, CustomAnnotationis the custom annotation name. While writing the custom annotations few points has to be considered. Method should not have any throws clauses, Similar to interface only declarations available…

Continue reading

Java se 8 Repeating Annotations

Repeating Annotations ( Java SE 8) In some cases we need to use Repeated Annotations as per the requirement @Retention(RetentionPolicy.RUNTIME) @interface CustomAnnotation { String city() ; int pin() default 123; } @CustomAnnotation(city = “Vijayawda”) @CustomAnnotation(city = “Chennai”) public static void testAnnotation() { System.out.println(“Custom annotation test”); } If you use repeated Annotations like this compiler will…

Continue reading

Static Import

Static Import The static import feature of Java 5 makes the programmer’s life a little bit simpler by accessing any static member of a class directly. No need of class name at all directly access by the name If you want to access any static member of a class often, by using this feature makes…

Continue reading

Java 8 Default methods and static methods

Java 8 Default methods and static methods One more new and useful feature introduced in Java 8 is default and static methods. From Java 8 onwards we can add concrete methods in Interfaces which is not possible in earlier versions. In other words Java enables to add non abstract method implementations to interfaces by using…

Continue reading