r/java • • May 21 '20

Java programming language celebrates 25 years

https://www.infoworld.com/article/3544229/java-programming-language-celebrates-25-years.html
309 Upvotes

38 comments sorted by

View all comments

12

u/OtherOtherNeRd May 21 '20

Anyone else want to write some programs in Java 1.0 for some frustrating nostalgia?

20

u/s888marks May 21 '20

It's not 1.0, but I had occasion to run a snippet of code on JDK 1.2 the other day to see how it behaved. Here's how it went:

// what I wanted
var strings = List.of("a", "b");

// get rid of var
List<String> strings = List.of("a", "b");

// get rid of collections factory
List<String> strings = new ArrayList<>(Arrays.asList("a", "b"));

// get rid of diamond
List<String> strings = new ArrayList<String>(Arrays.asList("a", "b"));

// get rid of generics
List strings = new ArrayList(Arrays.asList("a", "b"));

// get rid of varargs
List strings = new ArrayList(Arrays.asList(new String[] { "a", "b" }));

// oh that's ugly just add the strings explicitly
List strings = new ArrayList();
strings.add("a");
strings.add("b");

It was like going back in time....

19

u/schubart May 21 '20 edited May 21 '20

Go back further in time and you will have to switch to java.util.Vector...