import java.util.*;
import java.io.*; public class Loop { static Scanner console = new Scanner(System.in); public static void main(String[] args) { int i = 0;
int sum = 0; while ( console.hasNext() ) {
i = console.nextInt();
System.out.println(i);
sum = sum + i; } System.out.println("sum = " + sum); } }

这个代码,本来实验while和console.hasNext(),不知错在哪里

需要两次舒服EOF,  why????

The break and continue statements are an effective way to avoid extra variables to control
a loop and produce an elegant code. However, these statements must be used very sparingly
within a loop. An excessive use of these statements in a loop will produce a spaghetti-code
(loops with many exit conditions) and could be very hard to understand and manage.

As stated earlier, all three loops have their place in Java and one loop can often replace
another. The execution of a continue statement, however, is where a while structure
differs from a for structure. In a while loop, when the continue statement is executed,
if the update statement appears after the continue statement, the update
statement is not executed. In a for loop, the update statement always executes.

最新文章

  1. java基础知识(十一)java反射机制(上)
  2. 常见端口 HTTP代码
  3. C++ 小知识积累
  4. 精选12个时尚的 CSS3 效果【附源码下载】
  5. GCD,用同步/异步函数,创建并发/串行队列
  6. Spark源码系列(二)RDD详解
  7. HDU 1102 Constructing Roads
  8. Aptana快捷键(方便查询)
  9. 怎样对CODESOFT中的条形码进行黑白转换
  10. SQL 的一些概念问答
  11. dir()函数:罗列出参数所有的功能列表
  12. 用iframe框架,登录过期后登录框在框架里加载的问题
  13. 修改ScriptBundle 生成顺序
  14. for(var i=0;i<=3;i++){ setTimeout(function() { console.log(i) }, 10);}
  15. leetcode: 638.大礼包
  16. 九度 1482:玛雅人的密码(BFS)
  17. Android逆向-Android基础逆向7(内购干货集合)
  18. excel中CTRL+E的用法
  19. bzoj1729: [Usaco2005 dec]Cow Patterns 牛的模式匹配
  20. bzoj4753[JSOI2016]最佳团体

热门文章

  1. (四)Python中的“四大才子”(字符串、列表、字典、集合)
  2. Oracle问题整合
  3. istio环境搭建for macbook
  4. 在页面加载前先出现加载loading,页面加载完成之后再显示页面
  5. httpclient用getStatusCode
  6. 【模板】最长公共子序列(LCS)。
  7. 学习itop4412开发板有哪些资料可学习?能否学会
  8. CF1153D Serval and Rooted Tree
  9. eval()和$.parseJSON()注意事项
  10. Mac本地搭建kubernetes环境