The purpose of anonymous classes is clear and understandable. But I'm unable to find the minimum version of Java which supports anonymous classes. Can anyone tell me the exact Java version which supports it?
Asked
Active
Viewed 2,726 times
6
-
1I think Java 1, but i am not 100% sure – Jens Jul 27 '16 at 07:57
-
@Jens I can't find a mention in [the Java 1 spec](http://titanium.cs.berkeley.edu/doc/java-langspec-1.0/15.doc.html). – Andy Turner Jul 27 '16 at 08:00
-
The earliest mention I found, is in JLS 1.3 – Konstantin Yovkov Jul 27 '16 at 08:01
-
@KonstantinYovkov where do you find old language specs? I can only find 1 easily; then 6,7,8 on Oracle's website. – Andy Turner Jul 27 '16 at 08:02
-
Inner classes were added in Java 1.1 (see [Java version history](https://en.wikipedia.org/wiki/Java_version_history)), I guess anonymous classes were added around the same time. – Jesper Jul 27 '16 at 08:02
-
@AndyTurner, here I found [1.2](https://books.google.bg/books?id=Ww1B9O_yVGsC&pg=PR2&lpg=PR2&dq=java+language+specification+version+1.2&source=bl&ots=Sf4LdgRaoI&sig=WnLez614rlc9zYhDuoeQ17I3bCg&hl=bg&sa=X&ved=0ahUKEwjAp_qwlpPOAhXoLcAKHYo7BBAQ6AEIYDAI#v=onepage&q=java%20language%20specification%20version%201.2&f=false), and here I found [1.3](https://docs.oracle.com/javase/specs/jls/se6/html/j3TOC.html) – Konstantin Yovkov Jul 27 '16 at 08:03
-
@Konstantin thanks. – Andy Turner Jul 27 '16 at 08:05
-
Thank you all for your comments. – Udhaya Kumar K Jul 27 '16 at 08:10
-
https://books.google.ca/books?id=Ww1B9O_yVGsC&q=anonymous%20class confirms that they were part of 1.2 (under Inner Classes) – Autonomy May 23 '17 at 06:05
-
2I see they were part of 1.1. Please check https://www.cs.cornell.edu/andru/javaspec/1.1Update.html – Alex Oct 09 '17 at 14:28
1 Answers
7
Java 1.1
Source: https://www.cs.cornell.edu/andru/javaspec/1.1Update.html
Details: Added along with inner classes. Anonymous classes are a type of Inner Class (https://en.wikipedia.org/wiki/Inner_class). Inner classes were introduced in Java 1.1 (https://en.wikipedia.org/wiki/Java_version_history).

Curtis Yallop
- 6,696
- 3
- 46
- 36