• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Collection doubt #1

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
omkar patkar
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
omkar patkar
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Henry.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic