将用户输入字符串转换为大写Java [英] Turn a User Input String to Upper Case Java
本文介绍了将用户输入字符串转换为大写Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这似乎是一个愚蠢的问题,但是经过google页面之后,我无法找到我想要的答案.
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.showInputDialog("Enter Name: ");
对于上面的fo代码,我将如何格式化用户输入的全部为大写字母的数据?
For the above piece fo code, how would i format the data the user entered to be all capitals?
这里的任何帮助将不胜感激.
Any help here would be appreciated.
推荐答案
String类具有toUpperCase()方法.
The String class has a toUpperCase() method on it.
JOptionPane.showInputDialog(..)返回一个字符串,因此您可以使用:
JOptionPane.showInputDialog(..) returns a String, so you can use:
JOptionPane.showInputDialog("Enter name: ").toUpperCase();
这篇关于将用户输入字符串转换为大写Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文