【发布时间】:2016-08-17 02:39:49
【问题描述】:
我已经实现了以下代码来打印小写字符的短语:
import java.util.Scanner;
public class LowerCase{
public static void main (String[] args) {
String input, output = "", inter;
Scanner scan, lineScan;
scan = new Scanner(System.in); // Scan from the keyboard
System.out.println("Enter a line of text: ");
input = scan.nextLine(); // Scan the line of text
lineScan = new Scanner(input);
while (lineScan.hasNext()) {
inter = scan.next();
output += inter.toLowerCase() + " ";
}
System.out.println(output);
}
}
我不知道我的实现有什么问题!它可以正常编译,但是当我运行代码并输入输入短语时,它会冻结。
【问题讨论】:
标签: java java.util.scanner next lowercase scanline