Lets assume i have this very very simple code. What I want is to convert it into Lambda expressions explicitly.
Here is the code:
import java.lang.reflect.Method;
public class test {
float decrement = 1f;
float speed = 0.15f;
public test() {
for (;;) {
run();
}
}
private void run() {
try {
update(this.getClass().getMethod("print"));
} catch (Exception e) {
e.printStackTrace();
}
}
private void update(Method myCustomMethod) throws Exception {
if (decrement <= 0) {
myCustomMethod.invoke(this);
decrement = 1f;
} else {
decrement -= speed; // 1 * 0.15 =
System.out.println(decrement);
}
}
public void print() {
System.err.println("something");
}
}
How will i go about converting the Java reflection parts into pure lambda expressions?
Aucun commentaire:
Enregistrer un commentaire