Hacker News new | ask | show | jobs
by anothernewdude 1990 days ago
I know, right? In Java 1.4 you cast to Object, in Go you cast to interface{}. Totally different.
1 comments

Most of the casting in Java 1.4 was from collections of Object. In Go the collections are typed, so the casting is confined to some very specialized pieces of code.
The only difference between Go and Java 1.4 in terms of collections is that Go has a generic map type, which Java didn't. Java 1.4 still had generic arrays, just like Go. In fact, it was a little easier to program with generic arrays in Java vs Go (but also less safe) because in Java a subtype[] can be passed to a function which takes a supertype[] (arrays are covariant).
Yeah, right because we never been there before.

    class IntList {
       private List objList;

    public add(int elem) {
       objList.add(Integer.of(elem));
    }

   }
Rest is left as exercise for the readers that never used Java generics, or C++ templates.