Linked Questions
13 questions linked to/from Is it possible to make anonymous inner classes in Java static?
1 vote
1 answer
552 views
Make anonymous class static - through static method [duplicate]
I have thoughts about the following design public void cntDownPossesion() { ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { ...
0 votes
2 answers
251 views
How is it possible to create Local class in Java static block? [duplicate]
From Java documentation: Local classes are classes that are defined in a block, which is a group of zero or more statements between balanced braces. You typically find local classes defined in ...
210 votes
4 answers
72k views
What is the difference between javac and the Eclipse compiler?
Is Eclipse's Java compiler just a wrapper around the same core that the javac program is wrapped around, or is it a separate compiler altogether? If the latter, why would they reinvent the wheel?
4 votes
9 answers
3k views
Are static anonymous classes definitely wrong in Java?
I've read elsewhere that a static anonymous class doesn't make sense - that all anonymous classes should be tied to an instance of the enclosing type. But the compiler let's you do it. Here's an ...
19 votes
1 answer
6k views
Where are Java final local variables stored?
Take the following example: public void init() { final Environment env = new Environment(); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { env....
2 votes
2 answers
2k views
Java - Anonymous class are static or not
I know it depends on the context in which the anonymous class has been written (static or non static method). but look this part of code: public class A { int fieldOfA; private static class ...
1 vote
1 answer
3k views
Flink Serialization Error
I'm trying to run the Label propagation protocol on my Apache Flink Gelly Graph. Here is my code: Graph<String, Long, String> ugraph = Graph.fromDataSet(vertex, edgeSet, env)....
2 votes
3 answers
386 views
Why can't a local class that extends an inner class access the inner class enclosing instance?
(I keep re-reading that question title and thinking about how ridiculous it must look, but I assure you that is the best description of the problem, and I have an actual application where this is the ...
1 vote
2 answers
1k views
How to change outer variable from anonymous inner class?
I have a local variable in my outer method that I want to change from an anonymous inner class. How can I do it? I tried the solution using a one element array described here public class ...
3 votes
1 answer
211 views
double brace initialization and "kind of" static anonymous class
Sometimes for testing I use quick "double-brace" initialization which creates anonymous nested class in Outer class, for example: static final Set<String> sSet1 = new HashSet<String>() { ...
1 vote
1 answer
250 views
Dispose JavaFX Tasks
I have a static BorderPane with ContextMenu insight Task Task task = new Task() { @Override protected Void call() throws Exception { ...
3 votes
1 answer
188 views
Prevent anonymous class from referencing outer members in Java
In Java, is there a way to explicitly prevent an anonymous class to reference the outer class or method's members/local variables?
0 votes
3 answers
213 views
Can Anonymous inner class instantiated within a static method has access to instance members of containing class?
I want to understand better the visibility of instance fields of containing class to an Anonymous inner class (AIC). There have been lots of talks that AIC has an implicit reference to the containing ...