java中输入空格存入字符数组中
如何把一个空格存入字符数组中,如以下程序```
Scanner scanner = new Scanner(System.in);
char[][] map = new char;
char ch = ' ';
for (int i = 0; i < map.length; i++) {
for (int j = 0; j < map.length; j++) {
ch = scanner.next().charAt(0);
map = ch;
}
}
for (int i = 0; i < map.length; i++) {
for (int j = 0; j < map.length; j++) {
System.out.println(map);
}
}
``` ch = scanner.next().charAt(0);
// 上面那一句代码改成
ch = scanner.nextLine().charAt(0);
niebaohua 发表于 2021-8-1 22:10
ch = scanner.next().charAt(0);
// 上面那一句代码改 ...
但是我想的是不换行 nianxinzhuo233 发表于 2021-8-2 09:17
但是我想的是不换行
C:\Users\ASUS\Desktop
页:
[1]