Hi guys :D..

just wondering.. when I'm using scanner this is the code I use to ignore the case
"to put in the do..while statement"

} while (choice.trim().equalsIgnoreCase("Y"));

I've been looking all over the net. what code should I use if I'm using JOption..
can anybody please help me on this??

inputString = JOptionPane.showInputDialog(null, "Do again? [Y/N]: ");
          choice = inputString.charAt(0);
} while (choice != 'N');

what code should i put in the green part??

Recommended Answers

All 7 Replies

Convert the user input to upper-case, then compare it to upper-case 'N'.

} while (choice != 'N' || choice != 'n');

you mean like this?? @_@

sorry I'm still a beginner I feel kind of lost here.

} while (choice != 'N' && choice != 'n');

:D ah wait, this one work. although I don't know if there are other ways to do it

Those will work as long as "choice" is a char. (or...)

} while (Character.toUpperCase(choice) != 'N');

thines: I'm pretty sure the charAt(index method will return a char

Yes, of course.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.