Exception in thread "main" java.lang.NullPointerException: Canvas3D: null GraphicsConfiguration
Paul Clapham wrote:It isn't the loop which is the problem. The problem is that you declared the answerRow variable inside the loop, thus restricting its scope so that it is only visible to code inside the loop. Since you want it to be visible outside the loop, then you have to declare it outside the loop.
Don't confuse declaring the variable (int answerRow) with assigning a value to it (answerRow = answerID.getInt(1)). You can do those two things separately, and in this case you should. Declare the variable outside (before) the loop, assign it the value inside the loop.
Wendy Gibbons wrote:resultset.next() tells you if there are any more rows in the result set.
Remember a result set can contain many columns for a single row, and lots of rows.
this page has a full example of how to use result sets.
Bear Bibeault wrote:
Brendan Cregan wrote:i was confused with the assignment since it worked for !=
That's not an assignment, that's just another of the comparison operators: == != <= >=
The = operator is assignment, not comparison.
Manish Sridharan wrote:Hi,
In the below code you are not comparing the value of the variable instead assigning value of the answer variable to the variable myChoice.
Bear Bibeault wrote:If you had added debug statements like I hinted at, you would have found the assignment error noted above.
A couple of other points:
Your form is generating a GET. A doPost() will not be called unless you specifically call it from doGet() (which is bad paractice). Match the method to the form. Never re-invent the wheel. Look on the Boolean class to see if there's a conversion that you can use instread of writing your own. Once you find the above, it will tell whether 0 and 1 are good choice for the values.