首页 > 编程语言 > 详细

键盘输入,输出int数组的函数

时间:2017-11-29 17:59:49      阅读:218      评论:0      收藏:0      [点我收藏+]
public class function {
public static void main(String[] args) {
//输入数组数据(例如10个)
int [] array = inPut();
     System.out.println(Arrays.toString(array));
  }
  /*输入数组数据*/
  private static int[] inPut() {
  int [] array = new int[10];
  for(int n=0;n<10;n++){
  Scanner scanner = new Scanner(System.in);
  System.out.print("输入第"+(n+1)+"个数 :");
  int n1 = scanner.nextInt();
  array [n] = n1;
  }
  return array;
  }
}

键盘输入,输出int数组的函数

原文:http://www.cnblogs.com/bili-bili-fun/p/7921515.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!