This article is a mirror article of machine translation, please click here to jump to the original article.

View: 17844|Reply: 0

[Source] Java array sum code

[Copy link]
Posted on 10/15/2014 7:43:05 AM | | |


  1. /**
  2. *
  3. */
  4. public class Sum {

  5.         public static void main(String[] args) {
  6.                 int[] list = new int[] { 8, 4, 2, 1, 23, 344, 12 }; // 创建数组并赋值
  7.                 int sum = 0;
  8.                 for (int i = 0; i < list.length; i++) { // 循环输出
  9.                         sum = sum + list[i];
  10.                 }
  11.                 System.out.println("和是:" + sum);
  12.         }
  13. }
Copy code
Java array sum code




Previous:Java input lines print diamonds
Next:[Magic Revealed] [Global Magic Banned Documentary] Reveals the truth of magic
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com