Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Everything is in a class. Everything. Even poor little printf or the main function.


Although Java puts everything in an class, not everything in Java is an object. For instance, you can't write:

    Package p = java.lang;
    Class x = p.String;
    x y = "Hello";
    Method z = y.substring;
    w = z(0, 5);


That's just the syntax failing to support such a nice way of accessing those objects. Packages, classes, and methods are objects.

Of course, primitives are not objects, but autoboxing helps.


Sure, they're represented as objects in the JVM, and you can access this via refection; but they're not treated as objects in Java's syntax. I'd argue that OOP is a property of a language's syntax, rather than how it is internally represented.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: