大家都知道,Scanner在常量中是Scanner sc=new Scanner();int x=sc.nextInt();
那Scanner在String中怎么运用呢?以下面例子为例:public class Array {
public static void main(String[] args) {
int[] arr={98,23,16,35,72};
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
}
}
Scanner在字符串中是Scanner sc=new Scanner();String x=sc.nextIine(); |
|