|
|
Re: java.lang.Object is a class?
|
Posted: Mar 30, 2003 6:58 AM
|
|
> Yet, I still wonder why they didn't choose char[] or > something like that.
Maybe to make programming easier. If Object was an interface, we would to: - implement its methods in every class, or - extend explicitly a concrete class that implements that interface And it wouldn't guarantee that every class is subclass of Object. Another option would be extending implicitly a concrete class that implements that interface (that would be the same as extending the current Object class)
And, if the "String toString()" was "char[] toCharArray()" instead, would you be happy having to write "System.out.println(new String(obj.toCharArray()))" instead of "System.out.println(obj)"? (if you follow the rule of not making any attribute public, it would be "System.getOutputStream().println(new String(obj.toCharArray()))"
Bad design isn't the design that doesn't follow the OO rules strictly, is the design that doesn't achieve what it is intended to. A good design should do what it is intended to do, in a clean and simple way. In the case of APIs, it should ease programming.
|
|