🔥🔥🔥Java 8 Feature: Method Reference and Interview Questions🔥🔥🔥

Опубликовано: 26 Сентябрь 2021
на канале: tech for geeks💡
191
13

Lambda Expression --    • 🔥🔥🔥Java 8 Feature : Lambda Expression expl...  

Method Reference for Static and Instance Method:
--------------------------------------------------------------------------------
interface FuncInterface{
int calculation(int x);
}
public class MethodReference {
public int cubeOfNumber(int x){
return x*x*x;
}
public static void main(String args[]){

FuncInterface fObject=MethodReference::squareOfNumber;// static
int squareOfNumber = fObject.calculation(4);
System.out.print("Square of Number : "+squareOfNumber);

MethodReference methodReference=new MethodReference();//instace
FuncInterface fObject1= methodReference::cubeOfNumber;
int cubeOfNumber = fObject1.calculation(4);
System.out.print("Cube of Number : "+cubeOfNumber);
}
public static int squareOfNumber(int x){
return x*x;
}
}
========================================================
Method Reference Constructor :
-------------------------------------------------
interface Functional{
void print(String str);
}
public class MethodRef2 {

MethodRef2(String str){
System.out.print("Message is :"+str);
}

public static void main(String args[]){
Functional func= MethodRef2:: new;
func.print("Hello");

}
}


На этой странице сайта вы можете посмотреть видео онлайн 🔥🔥🔥Java 8 Feature: Method Reference and Interview Questions🔥🔥🔥 длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь tech for geeks💡 26 Сентябрь 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 191 раз и оно понравилось 13 зрителям. Приятного просмотра!