Nice. Yeah, that's using an anonymous inner class along with the "initializer block" I posted in one of my examples. With formatting, that translates into this:
import java.util.ArrayList;
import...
Type: Posts; User: KevinWorkman
Nice. Yeah, that's using an anonymous inner class along with the "initializer block" I posted in one of my examples. With formatting, that translates into this:
import java.util.ArrayList;
import...
Nice examples guys. I just thought of another one, referring to an outer class's "this" reference from an inner class:
public class InnerClassTest {
public InnerClassTest(){
OuterClass oc...
Hahahaha. Those are awesome. I'm going to start using them as often as possible at work and just wait for a code review...
And finally, how do you create an instance of a public non-static inner class? This is how:
public class InnerClassTest {
public InnerClassTest(){
OuterClass oc = new OuterClass();...
I stumbled across another example when a coworker of mine asked why his static block wasn't working (he was missing the static keyword):
public class BlockTest {
public static int x = 0;
...
Hey all,
We all know that Java is the best language ever and it always makes absolute syntactic and semantic sense, but occasionally I'll come across some syntax that makes me say, "huh?".
...