I am stumped by this error :
age cannot be resolved to a variable
I have everything correctly done so I am not sure why I am getting this error in my servlet :
My getter and setter
Hope someone can help me. Tks.
Perhaps you could show us the entire code of the servlet?
Read https://docs.oracle.com/javase/tutorial/java/nutsandbolts/expressions.html to learn about blocks
Campbell Ritchie wrote:You need a loop to ensure you get a valid number, and I would suggest you use the hasNextInt or similar method of Scanner to verify that input.
As this code is in a servlet, it can't work quite like that. But yes, processing can't continue if a required input is invalid.
Dave Tolls wrote:I doubt Eclipse was the culprit for the error in your original post.
If you remove the try/catch then yes, age will be visible to the later line where you use it to construct a Tutor...that's not Eclipse having a problem, though.
Before I had try/catch, I was getting the same error.
I then used the advice from stackoverflow to have try/catch.
And now I re-start my Eclipse, it was ok.