总结:对象调用方法,与在main 里直接输出没什么大的区别,少用方法,

乱搞++++

package com.c2;

import java.util.Scanner;

public class DD {

	// 求数组的平均值即 :a[i]/a.length

	public static void main(String[] args) {
Scanner c = new Scanner(System.in);
int a[] = new int[4];
DD b = new DD();
// DD d=new DD();
/*
* System.out.println("请输入10个数-----"); int b=c.nextInt(); int
* b1=c.nextInt(); int b2=c.nextInt(); int b3=c.nextInt(); int
* b4=c.nextInt();
*/// 很sb啊。这么手打出来会累,会繁琐,不如用循环.比如放入10000个数,我难道要写10000行、??
double s = 0;
for (int i = 0; i < a.length; i++) {
System.out.println("请输入第" + (i + 1) + "个数---");
a[i] = c.nextInt();
s += a[i];
// System.out.println(""+s); }
System.out.println("平均值为:" + s / a.length);
System.out.println("总和为:" + s); } }

  

最新文章

  1. java.lang.IllegalArgumentException: &#39;sessionFactory&#39; or &#39;hibernateTemplate&#39; is required
  2. MVC 多语言记录1 设置默认的ResourceType
  3. swiper 技巧
  4. JAVA基础学习之XMLCDATA区、XML处理指令、XML约束概述、JavaBean、XML解析(8)
  5. https和http共存的nginx配置
  6. 常见设计模式解析和实现(C++)Prototype模式(原型模式)
  7. 【HDU】 1018 Big Number
  8. NopCommerce 3.3中文语言包发布下载及使用
  9. Delphi 获取北京时间(通过百度和timedate网站)
  10. 【转】CodeGear RAD 2007 SP4
  11. DateTime.ParseExact
  12. 《CLR Via C#》读书笔记,持续更新...
  13. MongoDB存储引擎(下)——In-Memory
  14. 织梦cms网上复制图片不可用的解决方法
  15. Python系列-python函数
  16. 关联管理器(RelatedManager)
  17. 神经网络中的偏置项b到底是什么?
  18. Ruler.java
  19. MATLAB 的unique函数——数组矩阵的唯一值
  20. linux常用命令:sudo 命令

热门文章

  1. git生成和检查秘钥操作
  2. Spring 自定义标签配置
  3. ffmpeg的centos、msys2、msvc编译
  4. Hosts文件路径及修改方法
  5. Agilent RF fundamentals (5)
  6. C#基础知识梳理系列
  7. Activity步骤
  8. Intellij IDEA基于Springboot的远程调试
  9. debounce与throttle区别
  10. mac brew安装使用卸载