You can learn Java with me as the Java Programming language is being made easily. It would take a period of minimum three months and maximum 6 months to master Java. I would recommend you to watch all my videos to crack any software interviews that would require Java Programming language as a primary skill.
Primitive Type Functional Interfaces in JDK1.8:-
=================================================
1. Autoboxing
==============
The Automatic conversion of Primitive Types to their Corresponding Wrapper classes is called as Autoboxing.
This will be done by the compiler automatically and it was introduced in JDK 1.5 Version.
Example:-
==========
class A
{
public static void main(String[] args)
{
Integer i=100;
System.out.println(i);
//From Java 1.5 version, the compiler takes care of the conversion
//Compiler will convert the Primitive type to the Wrapper class time
//Automatically,and, you call this conversion as Auto Boxing.
}
}
2. Auto Unboxing:-
=================
The Automatic conversion of Wrapper class type to their Corresponding Primitive types is called as Auto Unboxing.
This will be done by the compiler automatically and it was introduced in JDK 1.5 Version.
public static void main(String[] args)
{
Integer i=new Integer(10);
int x=i;
System.out.println(x);
//int x=i.intValue();
//Auto Unboxing
}
3. Generic - Type Parameter
==============================
Please be informed that in the Collection classes when you are dealing with the homogeneous data type, the Type parameter should always be of Wrapper class type and primitive types are not accepted.
Primitive Type Functional Interfaces in JDK1.8
===============================================
Please be informed that to Over come the continuous process of Autoboxing and AutoUnBoxing by the compiler for the Normal Predicate which accepts int type as an input, we can opt for Primitive Type Functional as there would be a lot of Autoboxing and AutoUnboxings.
1. When you are dealing with the large set of primitive data types such as int,long, double as the input, you can opt for Primitive type functional interface and there are 3 primitive type functional interfaces designed for Predicates
1. IntPredicate
2. LongPredicate
3. DoublePredicate
Syntax:-
interface IntPredicate
{
//There is no type Parameter
//It is used to accept int as the primitive type
public boolean test(int i);
}
interface LongPredicate
{
//There is no type Parameter
//It is used to accept long values as the primitive type
public boolean test(long i);
}
interface DoublePredicate
{
//There is no type Parameter
//It is used to accept double values as the primitive type
public boolean test(double i);
}
Негізгі бет Java 8 features - class 18- Primitive Type functional Interfaces for Predicate-Explained in Detail
Пікірлер: 4