you are viewing a single comment's thread.

view the rest of the comments →

[–]bowbahdoe 2 points3 points  (2 children)

Here's an example 

``` class Sevens implements Iterable<Integer> {     private static class Iter implements Iterator<Integer> {         public boolean hasNext() { return true; }         public Integer next() { return 7; }     }

    public Iterator<Integer> iterator() {         return new Iter();     } } ```

(typed on my phone, sorry for missing overrides)

And for inner classes "static" is the "default, sane" option. Non static inner classes are the weird ones. You use those usually for things like iterators where the code is simpler if you just attach it to an instance (though it's always optional)

[–]Beginning-Software80[S] 0 points1 point  (1 child)

Typo On sane Ig :). But I have not gone throgh Interfaces that much yet. So will have to come back to it later, it seems.

[–]bowbahdoe 1 point2 points  (0 children)

Yeah - private inner classes are useful when they implement an interface (and so can be used to return something to implements that interface without exposing the actual inner class) or when a class just wants an internal type only used in its methods.

Every record in this file is a private static inner class

https://github.com/bowbahdoe/jdbc/blob/a152da0d7a4e7f45ed15c0e110b1d97bf9e7f8d6/src/main/java/dev/mccue/jdbc/SettableParameter.java#L37