The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Re: Scanner Problem

There is a variable on line 41 that has a null value when the code is executed. Look at line 41, find the variable with the null value and backtrack in the code to see why that variable does not have a valid value.

Re: Scanner Problem

umur is an int variable. Primitive variables do not cause NPE. Only object variables can cause NPE when the code tries to use them to call a method for example.
What statement is line 41? What object variable is on that line? Does it have a value?

Re: Scanner Problem

ohh,, scanner is an object on that line and scanner doesn't have any value before.
so scanner have NULL value and umur take NULL value from it right?
so how should I do for solve it, I mean I want umur have a value from user input.