使用扫描器从用户输入填充字符数组,我们想知道如何使用扫描器从用户输入填充字符数组。" /> 使用扫描器从用户输入填充字符数组,array解决方案,编程入门教程" />
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Please enter elements..."); char[] a = sc.next().toCharArray(); System.out.println("Array elements are : "); for (int i = 0; i < a.length; i++) System.out.println(a[i]); } }