Turn a User Input String to Upper Case Java

后端 未结 2 947
半阙折子戏
半阙折子戏 2021-01-12 14:05

This may seem like a silly question, but after going through pages of google, i havnt been able to find the answer i want.

s1.setName(JOptionPane.showInputDi         


        
相关标签:
2条回答
  • 2021-01-12 14:45

    See String.toUpperCase()

    Remember that String is immutable, so this creates a duplicate string

    0 讨论(0)
  • 2021-01-12 14:55

    The String class has a toUpperCase() method on it.

    JOptionPane.showInputDialog(..) returns a String, so you can use:

    JOptionPane.showInputDialog("Enter name: ").toUpperCase();
    
    0 讨论(0)
提交回复
热议问题