Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Esto
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- NaveController controladorNave = new NaveController();
- controladorNave.initialize();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- // Se puede convertir en
- EventQueue.invokeLater(() -> {
- try {
- NaveController controladorNave = new NaveController();
- controladorNave.initialize();
- } catch (Exception e) {
- e.printStackTrace();
- }
- });
- /**
- * Cuando una interfaz (como Runnable) tiene un único método
- * puedes reemplazar la clase que implementa la interfaz por
- * ("parametros del método) -> { código del método }
- *
- * Por ejemplo si tenemos la interfaz
- * @FunctionalInterface
- * public interface Posicion {
- * public abstract Punto actualizaPosicion(Punto p);
- * }
- *
- * y un método en una clase que recibe un objeto que implementa Posicion
- * Punto this.punto = new Punto(5, 6);
- * public abstract void mover(Posicion pos) {
- * this.punto = pos.actualizaPosicion(this.punto);
- * }
- *
- * Podemos llamar al método haciendo
- * mover((this.punto) -> {
- * this.punto.x += 1;
- * this.punto.y += 1;
- * }
- *
- * Esto es lo mismo que
- * mover(new Posicion() {
- * public void mover(this.punto) {
- * this.punto.x += 1;
- * this.punto.y += 1;
- * }
- * });
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement