Questions tagged [anonymous-inner-class]

Anonymous Inner Classes are local classes that are declared and instantiated inline.

These are local classes that are declared and instantiated inline, often in the middle of an expression or as an argument of a method. They can only directly extend one class or implement one interface. They can specify arguments to the constructor of the superclass, but cannot otherwise have a constructor (however, this is not a limitation, since it can have an instance initializer block to perform any initialization).

246 questions
-1
votes
1 answer

java-outer separate class access anonymous class

Supposing I have the following classes Class0 public abstract class Class0 { public Class0(){} public void abmethod1(){ System.out.println("Abstract method 1"); } public void abmethod2(){ System.out.println("Abstract…
Vassilis De
  • 363
  • 1
  • 3
  • 21
-1
votes
1 answer

Use of Anonymous Inner Class in java

public SampleBehaviour otherway(final String st) { return new SampleBehaviour() { private String str = st; @Override public void print() { System.out.println("val:"+val); } }; } SampleBehaviour…
Dineshkumar
  • 4,165
  • 5
  • 29
  • 43
-2
votes
2 answers

Right way to test performance of Lambda expressions?

I have used JMH to test the performance of Lambda against Anonymous Inner classes and below is how I did it: public class LambdaVsAnonymousClass { @Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) public void…
Rehna Roy
  • 13
  • 2
-2
votes
2 answers

What calls a method inside an anonymous inner class?

In the example program on https://gist.github.com/bernii/5697073 In the code this.wait.until(new ExpectedCondition() { public Boolean apply(WebDriver webDriver) { System.out.println("Searching ..."); …
danger mouse
  • 1,457
  • 1
  • 18
  • 31
-2
votes
1 answer

Creating inner anonymous classes that extend other classes

I know this works: class Main{ public static void main(String[]args){ AbstractClass object = new AbstractClass(){ ... }; } } It creates an object with implicitly extends the AbstractClass class (Which is obviously abstract). But…
Aviv Cohn
  • 15,543
  • 25
  • 68
  • 131
-3
votes
2 answers

What calls the greet() method in HelloWorldAnonymousClasses?

In the HelloWorldAnonymousClasses example program (from here): /* * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted…
danger mouse
  • 1,457
  • 1
  • 18
  • 31
1 2 3
16
17