aspose file tools*
The moose likes Beginning Java and the fly likes Need answers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need answers " Watch "Need answers " New topic
Author

Need answers

Vinay Gangoli
Greenhorn

Joined: Jun 13, 2003
Posts: 22
hi all,
i have some qs i cant find reliable ansswers too...
1) if i dont enclose the wait(), notify(), and notifyall() functions within synchronized loop...what do i get?. Compile time error or runtime error ?
2) I read that i cant just override
boolean equals(object o)and get away with it. That is i have to override hashCode() too. But i just did. I am a bit confused. Comments please.
3)can i have static variables inside of anonymous/method local innerclasses ?
answres to any of these will help me a lot...thanks in advance


SCJP 1.4<br />" Somedays ur the dog...other days ur the water hydrant "
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
1) if i dont enclose the wait(), notify(), and notifyall() functions within synchronized loop...what do i get?. Compile time error or runtime error ?
Runtime. Specifically IllegalMonitorStateException.
2) I read that i cant just override boolean equals(object o)and get away with it. That is i have to override hashCode() too. But i just did. I am a bit confused. Comments please.

It's OK so long as you don't use a HashMap or Hashtable since they use the hashcode to determine unique keys. But you really should override hashCode() any time you override equals(). Specifically: If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.

3)can i have static variables inside of anonymous/method local innerclasses ?

Nope.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Vinay Gangoli
Greenhorn

Joined: Jun 13, 2003
Posts: 22
Thanks Michael...that helped...Vinay
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need answers