• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is Sun Fooling US  RSS feed

 
sachin verma
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my first ever post in this forum so first I want to say Hi to all.

Now I have been using JAVA Documentation from a long time.
And because it was released from sun too, I did not expect any flaw in it.
But now I don't trust it at all.
Reason is
For instance when I see System class Documentation in jdk-1_5_0-doc\docs\api\java\lang\System.html
It shows that System is a final class and it is also a direst subclass of Object.
like the below->>>>>>>
public final class System
extends Object

But when I see System.java file in jdk1.5.0_14\src\java\lang\System.java
It shows something like this

package java.lang;

import java.io.*;
import java.util.Properties;
import java.util.PropertyPermission;
import java.util.StringTokenizer;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.AllPermission;
import java.nio.channels.Channel;
import java.nio.channels.spi.SelectorProvider;
import sun.net.InetAddressCachePolicy;
import sun.nio.ch.Interruptible;
import sun.reflect.Reflection;
import sun.security.util.SecurityConstants;
import sun.reflect.annotation.AnnotationType;


public final class System {
//Specific code
}




My Question is "Why this Difference Exists ?"
And what is the purpose of Documentation then If it does not provide the correct n Exact information?

I am preparing for scjp 310-055
I have been using java from last 3 years.


[Removed non-words from subject line]
[ April 21, 2008: Message edited by: Ben Souther ]
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Difference? I don't see a difference.

As you see in the source code, class System is indeed final. You never need to extend class Object explicitly - classes that don't extend a superclass implicitly extend class Object.

So the information in the documentation is correct.

Also, please pay attention to the following: Here on JavaRanch, we have a naming policy. We want the users of JavaRanch to use a real-sounding name as their display name.

Your name "scjp sachin" is not a real name. So please change your name in accordance to the naming policy. You can change your name by editing your profile.

Please note that we are taking the naming policy seriously. If you do not change your display name, your account on JavaRanch might be locked.
[ April 21, 2008: Message edited by: Jesper Young ]
 
sachin verma
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for telling me the naming policies..I have changed it.

Are you trying to say that every class that we construct is implicitly a direct subclass of Object class (that is on the top).Or it provides us its infomation through hierarchy.
like
Object-->SomeClassesToSupportThreading-->SomeClassesToSupportException-->etc etc-->UserClass

If it provides through hierarchy then isn't it important then whenever someone uses the direct sub classing from Object...he/she should provide the exact way of using.
Does it matter to subclass direct from Object, Or through hierarchy ??
.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java has a singly rooted hierarchy, meaning that a single class (java.lang.Object) is at the top of the hierarchy for all objects.

As the JLS states under section 4.3.2, "The class Object is a superclass (�8.1) of all other classes."
 
sachin verma
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So isn't it necessary to mention that thing???


With Java, if you don't specify the class that you are extending, it will be defaulted to the java.lang.Object class.

Meaning there is no difference between this...

class MyClass extends Object

And ....

class MyClass

Henry
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now suppose u r writing documentation about java API's.

Please use real words when posting to the forums. Abbreviations such as "u" in place of "you" and "r" in place of "are" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff

P.S. While it's a good idea to surround code with CODE tags, you shouldn't do so for plain text. Using CODE tags to get around the "real word" policy will not be well received.
 
Gavin Tranter
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Everybody" knows that a class that dosnt extend any other class is implicitly extending from Object, there is no need to state this in the documentation.

Having said that, the sun java doc for the System class does tell you that it extends Object, its pretty much the first thing the documentation tells you.

Even for objects that dont directly extend Object, such as ChangeEvent it gives you the inheritaince tree and it tells you that the root Class is Object.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!