| Author |
driver manager
|
ravindra patil
Ranch Hand
Joined: Sep 01, 2006
Posts: 196
|
|
having top level class is meaningless but in jdbc DriverManager is static class so why this is sattic t  [edited to use a meaningful subject line - was "how is this"] [ October 18, 2006: Message edited by: Jeanne Boyarsky ]
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26184
|
|
Originally posted by ravindra patil: having top level class is meaningless
Why is it meaningless?
It is static so you can call it without having to create an object.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
ravindra patil
Ranch Hand
Joined: Sep 01, 2006
Posts: 196
|
|
Originally posted by ravindra patil: having top level class is meaningless but in jdbc DriverManager is static class so why this is sattic t [edited to use a meaningful subject line - was "how is this"] [ October 18, 2006: Message edited by: Jeanne Boyarsky ]
oh......jeanne you don't require class object if class's method is static if your method is static then though your class is static you want object of it ,if you really know the answer then give it otherwise don't what is the perpose behind having it as a static most of the java book mention that having top leval class is meaningless
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8143
|
|
if you really know the answer then give it otherwise don't
Ravindra, everyone here tries to help others voluntarily. Please be nice to everyone, whenever you are posting in the forums. Also, what Jeanne has mentioned in her answer is correct. We dont see anything wrong in what she has mentioned. [Jaikiran: Edited message, since there was a mistake in addressing Jeanne] [ October 19, 2006: Message edited by: Jaikiran Pai ]
|
[My Blog] [JavaRanch Journal]
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8143
|
|
most of the java book mention that having top leval class is meaningless
I havent read this before. Any reference?
|
 |
ravindra patil
Ranch Hand
Joined: Sep 01, 2006
Posts: 196
|
|
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8143
|
|
From the link that you mentioned:
A top-level class is by definition already top-level, so there is no point in declaring it static; it is an error to do so. The compiler will detect and report this error.
And here's the javadoc of DriverManager: DriverManager Where did you find that the DriverManager class itself is declared as static? Only the methods of that class have been declared as static.
|
 |
ravindra patil
Ranch Hand
Joined: Sep 01, 2006
Posts: 196
|
|
Originally posted by ravindra patil: having top level class is meaningless but in jdbc DriverManager is static class so why this is sattic t [edited to use a meaningful subject line - was "how is this"] [ October 18, 2006: Message edited by: Jeanne Boyarsky ]
man, just read JDBC section of Professional java server progreamming 1.3 edition by wrox publication and 'read it carefully'
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26184
|
|
From your link, "Each top-level class corresponds to its own java file sporting the same name as the class name.". This is the most common type of class. It is certainly not meaningless. The link goes on to say "A top-level class is by definition already top-level, so there is no point in declaring it static; it is an error to do so." I think this is what we are discussing. The DriverManager class follows a pattern called a "utility class." This is where all the methods are static.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26184
|
|
Jaikiran: Just want to mention that I am female. Ravindra:
if you really know the answer then give it otherwise don't
Sometimes people (especially the moderators here) ask questions to help you elaborate your question. The alternative is everyone remaining silent because they don't understand the question and then you don't get any help. Note that the rolleyes icon is often construed as being upset with someone. That's probably not what you wanted to portray in a technical forum. Just mentioning this so you are away of the perception of this icon. (Smilies are disabled in this forum anyway, so you may want to ease up on their use here.)
|
 |
ravindra patil
Ranch Hand
Joined: Sep 01, 2006
Posts: 196
|
|
Originally posted by ravindra patil: having top level class is meaningless but in jdbc DriverManager is static class so why this is sattic t [edited to use a meaningful subject line - was "how is this"] [ October 18, 2006: Message edited by: Jeanne Boyarsky ]
Jeanne i am sorry from where are you i ask this question because interviewer asked me that question i answered top less class is never static but when i was reading professional java server programmming 1.3 edition by wrox publication it is clearly nentioned that DriverManager is staic class but document on static on java world shows that having top level class as static is error and compiler gives error
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8143
|
|
Originally posted by Jeanne Boyarsky: Jaikiran: Just want to mention that I am female.
Sorry Jeanne, i was unaware.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26184
|
|
professional java server programmming 1.3 edition by wrox publication it is clearly nentioned that DriverManager is staic class
Ravindra: Sometimes people/books make mistakes or are misleading. Since you are finding web articles and people (in this forum) who are stating top level classes cannot be static, I think the book meant that DriverManager contains static methods, not that it is a static class. Jaikiran: It's not big deal. I just wanted to mention it.
|
 |
 |
|
|
subject: driver manager
|
|
|