• Post Reply Bookmark Topic Watch Topic
  • New Topic

Class OR object ???  RSS feed

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System is a class,....but what is System.out (is it an obj. or class) ? Also incase of Map, its an interfaces, then whats Map.Entry ? Why ?
 
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System is a class. System.out is a static member of that class -- an object of type PrintStream. Map is an interface, and Map.Entry is another interface nested inside it.

It really sounds like you need to buy an intro Java book; you might consider a copy of "Head First Java".
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read the API docs before posting any more questions.
 
omkar patkar
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot!..... i am learning java from The Complete reference Java 2, 3rd edition....and the thing is, when i had started, i found the book intersting and easy but now as i am moving towards advanced part of java.....i am getting absolute interest in java and want to peek into every depth of it!! (Java!...not the book ! ) ...but, the book is giving me little help and therefore i go for...java ranch!...i find it helpfull!....any one having problem with it ...i mean any problem with answering my doubts....or should i say the forum members also don't want to help me!..........previously...i think the moderator of this section was offende whats the problem ??
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the main problem is that most of your questions could be answered by reading the API docs or tutorials.
If you post loads of questions that could have been answered with a little research, it's likely that when you do have a more difficult question it will get overlooked because people have stopped reading your posts.
 
omkar patkar
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Acutually, as i said earlier, i refer hat book , practice few programs....sometimes even refer API docs!.....but when it things don't get cleared i ask them out here.....the first time i was told about this forum and when i had posted few doubts initially i was happy to get SO MUCH co-operation from forum members......now since i am learning advanced part of java i make a list of it and post my doubts in this section one by one .....why should any one overlook it ?.......E.g.....when i had doubt regarding "hashcode" ...i checked up in API doc.....in Date class it was given:-

hashCode
public int hashCode()Returns a hash code value for this object. The result is the exclusive OR of the two halves of the primitive long value returned by the getTime() method. That is, the hash code is the value of the expression:
(int)(this.getTime()^(this.getTime() >>> 32))
Overrides:
hashCode in class Object
Returns:
a hash code value for this object.

NOW !.....how exactly do you want me to "Reasearch" on this explanation from API doc?....because the doubt is ...why "exclusive OR " ?....does API doc provide answer to this ?.....another one .. WHERE on earth will we ever feel the need to use of hashcode for objects of type Date ?....if i don't know answer to these qusetions how can i understand the API docs? ...API DOCS being my only source after The Complete Reference Book?......what should i do? What ???
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The number one rule of JavaRanch is

Be Nice.

From time to time, people need to be reminded of this. Joanne, being rather new here, may need a gentle reminder, although really, I don't think she was too far out of line. Not really nice, but not exactly mean, either. But let's all take this as a reminder to treat each other kindly.

Joanne was probably reacting negatively because you posted so many questions all at once. Often that's something that people do when they have a list of test or interview questions that they want answers to. I don't think that's what you're doing here, but seeing all those posts from one person at a time is always suspicious. I can't really tell you what to do, except perhaps to get some better books (see below).

On the other hand, I can't say I agree with her directing you to the API docs for everything. The API docs tell you the details, but not the "big picture". Browsing the API docs is useful, but it can (as you've discovered) lead to more new questions than it answers.

A good introductory book can give you some of that big picture, but I have to tell you that any book with the word "Reference" in the title probably isn't going to give you that big picture.

The very best way to get that big picture, though, is experience. There are some Java questions, especially of the "When would I ever use this?" variety, that are hard to answer until you've had some Java programming experience.

As to your specific Date question: imagine, as just one example, that you want to look up holidays by date; perhaps you're writing some kind of a calendaring application. You could store Holiday objects (a class you define) in a HashMap, using Date objects as the keys. HashMap uses the hashCode() method of its keys to provide fast lookup.

Why "exclusive OR"? Because a good hash function will try to give similar objects very different hashcodes, so that a group of objects are "spread out" over the range of available values. Spreading the objects out makes hash-based containers like HashMap work more efficiently. If you want to learn more about this, Google for "hashtable algorithms".
[ September 23, 2005: Message edited by: Ernest Friedman-Hill ]
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by omkar patkar:
Acutually, as i said earlier, i refer hat book , practice few programs....sometimes even refer API docs!.....but when it things don't get cleared i ask them out here.....the first time i was told about this forum and when i had posted few doubts initially i was happy to get SO MUCH co-operation from forum members......now since i am learning advanced part of java i make a list of it and post my doubts in this section one by one .....why should any one overlook it ?.......E.g.....when i had doubt regarding "hashcode" ...i checked up in API doc.....in Date class it was given:-

hashCode
public int hashCode()Returns a hash code value for this object. The result is the exclusive OR of the two halves of the primitive long value returned by the getTime() method. That is, the hash code is the value of the expression:
(int)(this.getTime()^(this.getTime() >>> 32))
Overrides:
hashCode in class Object
Returns:
a hash code value for this object.

NOW !.....how exactly do you want me to "Reasearch" on this explanation from API doc?....because the doubt is ...why "exclusive OR " ?....does API doc provide answer to this ?.....another one .. WHERE on earth will we ever feel the need to use of hashcode for objects of type Date ?....if i don't know answer to these qusetions how can i understand the API docs? ...API DOCS being my only source after The Complete Reference Book?......what should i do? What ???


But your original question was not 'why does the hashCode method for Date return an exclusive OR of the two halves of the primitive long value returned by the getTime() method, which would have been a perfectly reasonable question. It was What is hashcode().
Do you see the difference ? Ask specific rather than vague questions and you are more likely to get an answer.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
The number one rule of JavaRanch is

Be Nice.

From time to time, people need to be reminded of this. Joanne, being rather new here, may need a gentle reminder, although really, I don't think she was too far out of line. Not really nice, but not exactly mean, either. But let's all take this as a reminder to treat each other kindly.

Joanne was probably reacting negatively because you posted so many questions all at once. Often that's something that people do when they have a list of test or interview questions that they want answers to. I don't think that's what you're doing here, but seeing all those posts from one person at a time is always suspicious. I can't really tell you what to do, except perhaps to get some better books (see below).

On the other hand, I can't say I agree with her directing you to the API docs for everything. The API docs tell you the details, but not the "big picture". Browsing the API docs is useful, but it can (as you've discovered) lead to more new questions than it answers.


Fair comment. It's nearly the end of the day here, so I'll resolve to be nice next week.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Ernest. The word "Reference" in the title implies to me that you should already know the language and use the book to look up details that you may have forgotten. I own many such reference books, but none of them was the first book that I read to learn the given topic. I suggest that you find a book that is intended for beginners, such as Head First Java by Kathy Sierra and Bert Bates. There are many other such books that are targeted directly at people that have never programmed in Java before. I think such a book would be much better for you at this point.

Regards,

Layne
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by omkar patkar:
System is a class,....but what is System.out (is it an obj. or class) ? Also incase of Map, its an interfaces, then whats Map.Entry ? Why ?


I would like to point out one thing in regards to your original question. The Java API follows a very common naming convention. That is all class and interface names start with an upper-case letter. All variable names (including object references) and method names start with a lower-case letter. If you understand this convention, then you can look at "System.out" and note that System is either a class or interface and out is a variable. Now you would have to look at the API docs to determine if out is an object reference or a primitive, but at the very least this rules out the possiblity that out is a class.

Now let's look at "Map.Entry". Using the same analysis, Map is probably a class or interface. Entry is also a class or interface. We use Map.Entry because the Entry interface is declared inside the Map interface.

Finally, I would like to suggest that you use this naming convention in your own code. It will help you quickly separate class names from variable names. It will also help us read your code more easily when you need to post it along with a question you have.

Keep Coding!

Layne
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!