WELCOME Abdennour : Software engineer

Jan 4, 2015

Refactor your Code from Old java to Java 8

هذا الدرس سيعلمك كيف تغتنم قوة الجافا 8 في تحسين كودك و تخفيفه

Indeed, many paradigms have been added to Java Language : 

1.Methods and lambdas as first-class citizens  : 
  OLD: 
       :
File[] hiddenFiles=new File(".").listFiles(new FileFilter(){
    public boolean accept(File file){
           return file.isHidden();
    }

});

    NEW :

File[] hiddenFiles=new File(".").listFiles(File::isHidden);

2. GUI event handling : 


     OLD
:
Button button = new Button("Send");
button.setOnAction(new EventHandler<ActionEvent>() {
     public void handle(ActionEvent event) {
                label.setText("Sent!!");
     }
});

     NEW :



button.setOnAction((ActionEvent event) -> label.setText("Sent!!"));

______________
سنتابع بإذن الله

No comments:

Post a Comment