About 124,000 results
Open links in new tab
  1. How are anonymous inner classes used in Java? - Stack Overflow

    Dec 10, 2008 · Anonymous inner classes are effectively closures, so they can be used to emulate lambda expressions or "delegates". For example, take this interface: public interface F<A, B> { …

  2. java - How to pass parameters to anonymous class? - Stack Overflow

    Is it possible to pass parameters, or access external parameters to an anonymous class? For example: int myVariable = 1; myButton.addActionListener(new ActionListener() { public void

  3. java - Why are only final variables accessible in anonymous class ...

    Only an effectively final variable can be used in an anonymous inner class or lambda expression though. It's basically due to the way Java manages closures. When you create an instance of …

  4. java - Accessing constructor of an anonymous class - Stack Overflow

    Dec 12, 2008 · The Java spec only specifies that the anonymous class, which is the offspring of the (optionally) abstract class or implementation of an interface, can not have a constructor by …

  5. java - Multiple inheritance for an anonymous class - Stack Overflow

    How can an anonymous class implement two (or more) interfaces? Alternatively, how can it both extend a class and implement an interface? For example, I want to create an object of …

  6. Access "this" from Java anonymous class - Stack Overflow

    Jul 5, 2009 · I want to access Container.select() from within my anonymous class' select() method. However, this.select() would again call the anonymous class' select() method.

  7. java - Calling newly defined method from anonymous class - Stack …

    My question is regardless of the fact that whether the supertype (class or interface ) has declared that method or not, anonymous class should be able to define its own method as written in the …

  8. java - When exactly is it leak safe to use (anonymous) inner classes ...

    Closures in Java are Anonymous Inner Classes, like the Runnable you describe. Its a way to utilize a class (almost extend it) without writing a defined Class that extends Runnable. It's …

  9. How can I write an anonymous function in Java? - Stack Overflow

    May 2, 2010 · Java 8 make it possible to define anonymous functions, which was impossible in previous versions. Lets take example from java docs to get know how we can declare …

  10. java - Java8 Lambdas vs Anonymous classes - Stack Overflow

    Mar 25, 2014 · Lambda performance with Anonymous classes When application is launched each class file must be loaded and verified. Anonymous classes are processed by compiler as a …