JavaRanch » Java Forums »
Java »
Java in General
| Author |
Java Collection doubt #1
|
omkar patkar
Ranch Hand
Joined: Aug 25, 2005
Posts: 231
|
|
Hi Guys, I was just working on my program based on collections, However when i run the program successively without making any changes in the code,....even then i get different results in my the console. I am using jdk 1.6 and Eclipse 3.1 Following is the code:- and When a runtime exception is thrown then how come i am able to see the SOP statements after the exception has been thrown as can be seen in output#2 ? ..... Can any one please tell if this the problem of the eclipse or my program ? Actually through this program i want to create a situation, so that the program throws an "UnsupportedOperationException". Can any one please guide me through as to how i can get the desired exception? ... Please ? Million thanks in advance ranchers! mkar Patkar.
|
Thanks and Regards
Omkar Patkar (SCJP 1.4)[url]http://javacollectionsnotes.blogspot.com[/url] | [url]http://omkar-myscjpexp.blogspot.com[/url]
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
|
This is about six times longer than anything I'd ever consider reading through to help someone, especially because, since it dies with an NPE at the end, 99% of the text is irrelevant. Sort through this and post again while providing only the information related to the actual question -- whatever it is -- and perhaps someone will be able to answer.
|
[Jess in Action][AskingGoodQuestions]
|
 |
omkar patkar
Ranch Hand
Joined: Aug 25, 2005
Posts: 231
|
|
Hi Ernest, Thanks for the prompt and short and sweet reply. I'll take care of that from next time. Here i thought that i would be more specific with my question, so i posted my code also. And its only because of the code that the length of the question appears to be too long. Also, Here i have mentioned what my problem was, and that is i am not able to understand why i get different outputs inspite of the fact that i run the same program without making any changes in it. Also, i think i was quiet clear to mention another problem that i am facing and that is how i can create a situation so that i get an "UnsupportedOperationException". Well, my first problem is solved. I have realized that it was due to Eclipse. But my second problem is still not solved. .... Can you please help me solve my second problem ? .... Or still 99% of the text is irrelevant ? Please let me know. May be i will go through the forum conventions and rules and regulation 99 times, so that i am not 99% irrelevant ! Once again Thanks Ernest!
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16692
|
|
Well, my first problem is solved. I have realized that it was due to Eclipse. But my second problem is still not solved. .... Can you please help me solve my second problem ? .... Or still 99% of the text is irrelevant ? Please let me know. May be i will go through the forum conventions and rules and regulation 99 times, so that i am not 99% irrelevant !
The relevancy has nothing to do with the rules. Think about it. If someone has a question for you, which are you more likely to answer? A short-to-the-point question? Or a question, attached to a long program, which 99 percent works? Ernest is pointing out that if you make your question more readable, maybe there is a chance that more people would actually read it!!! Anyway... This is saying that the addAll() method is encountering a null pointer exception. You don't have more info than this, but you can get more if you attach the Java source code to your IDE. But if I had to guess, you probably passed in a null pointer that it wasn't expecting.... like so... Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
omkar patkar
Ranch Hand
Joined: Aug 25, 2005
Posts: 231
|
|
Thank you Henry.
|
 |
 |
|
|
subject: Java Collection doubt #1
|
|
|
|