akila sekaran wrote:--------------------i get null pointer exception------------------
Bear Bibeault wrote:
akila sekaran wrote:--------------------i get null pointer exception------------------
Don't tell us, show us!
Post the stack trace. Be sure to UseCodeTags.
And please, lose all the needless dashes. They just make you post harder to read.
Bear Bibeault wrote:How did you know that you had a null pointer exception?
Wes McClintock wrote:I find that whenever I get null pointer exceptions, I find its almost always because I'm trying to access an element in an array that doesn't exist. For example, using array[5] when they array is only 5 elements long (meaning it would only go up to array[4]).
akila sekaran wrote:--------------------i get null pointer exception------------------
java.util.InputMismatchException
akila sekaran wrote:
Matthew Brown wrote:
akila sekaran wrote:
So in fact, then, it's not a NullPointerException at all?
The InputMismatchException is caused by trying to read an int from the Scanner when there isn't an int to read. Note that you check the next token is an int, but then you try and read two ints in a row. You need to look at what the input actually is.
This is the error that i iam getting . Sorry abt that Input Mismatch Exception.Matthew Brown wrote:
akila sekaran wrote:
So in fact, then, it's not a NullPointerException at all?
The InputMismatchException is caused by trying to read an int from the Scanner when there isn't an int to read. Note that you check the next token is an int, but then you try and read two ints in a row. You need to look at what the input actually is.
akila sekaran wrote:i got a NPE before but now when i executed i got this IME. Could you see the code and temme where i went wrong?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:It's kind of hard to tell you since:
1) You didn't post the exact and complete error you got
2) We don't know how to run this program
When you post a question here, your primary responsibility is to make it as easy as possible for someone to help you. I tried to run your program, but it is asking for a file name. I don't know what that file should be. Is it an input file, or is it for output? If it is input, what should be in it?
So If I wanted to help you, now I have to spend MORE of my time trying to figure out how to run this, which gives me less time to actually solve the problem. Many folks won't even bother.
So, please give us all the relevant information, and make it easy for us to help you, and folks will. Make it hard, and people will try but most likely give up.
akila sekaran wrote:
oh forgive me.. i am totally new to forum way of handling things..
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:
akila sekaran wrote:
oh forgive me.. i am totally new to forum way of handling things..
It's not a big deal - provided you get better. I was trying to give you some suggestions, but there is more info on our HowToAskQuestionsOnJavaRanch FAQ (click the underlined part). It gives some useful tips on how we work and how to get the best possible experience here.
N Tiwa wrote:You should be using arrayList as you don't need to specify the size and it grows dynamically. You can add an element to it just like you do with an array. You can find more on this here- http://docs.oracle.com/javase/6/docs/api/java/util/ArrayList.html