0

How do I use JOptionPane for Strings?

When I use JOptionPane.showInputDialog than I use ....charAt(0) for char and Double.ParseDouble and so on. What do I use for Strings? For example: If I want sb. to enter their name in the Input Dialog and if its equal to a specific name I entered, it must show sth else as if its an other name

17th Jun 2017, 9:36 AM
Julien Best
Julien Best - avatar
1 Answer
+ 11
The input of JOptionPane is by default in String, you don't need to convert it again. String name = JOptionPane.showInputDialog("Enter your name: "); if(name.equals("Julien")){ // write something }
17th Jun 2017, 9:48 AM
Shamima Yasmin
Shamima Yasmin - avatar