In Java can you do a function literal like you can in JavaScript?
JS example:
Code:var i = (function(){return 10;})();
Printable View
In Java can you do a function literal like you can in JavaScript?
JS example:
Code:var i = (function(){return 10;})();
No.
Java doesn't support anonymous functions of any kind. If you want to move methods around, you have to use the Method class from the java.lang.reflection package.