【发布时间】:2015-01-15 19:25:44
【问题描述】:
我想知道如何在我的方法中让用户输入的内容忽略大小写:
public static void findPatient() {
if (myPatientList.getNumPatients() == 0) {
System.out.println("No patient information is stored.");
}
else {
System.out.print("Enter part of the patient name: ");
String name = sc.next();
sc.nextLine();
System.out.print(myPatientList.showPatients(name));
}
}
【问题讨论】:
-
只需使用
toLowerCase或toUpper -
docs.oracle.com/javase/7/docs/api/java/lang/String.html 读取 toLowerCase() 和 toUpperCase()
-
或等于IgnoreCase()。
标签: java string uppercase lowercase