全部版块 我的主页
论坛 数据科学与人工智能 IT基础 JAVA语言开发
2274 19
2015-05-31

  • Java Programming
  • By: Hari Mohan Pandey

  • Publisher: Pearson India

  • Pub. Date: December 12, 2011

  • Print ISBN-10: 81-317-3311-4

  • Print ISBN-13: 978-81-317-3311-0

  • Web ISBN-10: 81-317-6536-9

  • Web ISBN-13: 978-81-317-6536-4

  • Pages in Print Edition: 880

  • Subscriber Rating: [5 Ratings] Subscriber Reviews



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2015-5-31 04:04:19
复制代码


Explanation: Here the statements after if expression are put in the braces. When the if condition is true, all the statements within the braces get executed; in case the condition is false, the statements within the braces are skipped. Regardless of true/falsity of if condition, the remaining statements are executed and so is the output. To execute only if-dependent statements, one will have to use if-else construct or terminate the program after the execution of if block. The second alternative is shown in the next program.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-5-31 04:05:44
复制代码

Explanation: In Java, if(x) is equivalent to if(!x 5 false) and x can only be Boolean value. Similarly, if(!x) is equivalent to if(x = = false).


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-5-31 04:08:45
复制代码

Explanation:
As discussed earlier, System.out is an object of class PrintStream so it is assigned to a reference pr of PrintStream type. Now instead of writingSystem.out.println, you can write pr.println. If the if condition x%2 = = 0 is true, the number is even, else the number is not even. The else part executes only when if part is false and vice-versa. In the program both if and else parts contain just one statement to be dependent on them so braces are not needed; however, if you put the braces there will not be any harm.


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-5-31 04:10:42
复制代码
Explanation:
  • Program is self-explanatory.

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-5-31 04:14:23
复制代码
Explanation:If the numbers are equal the first if condition is true else else block is executed. In the else part, there is one more if-else. If a > b is true then inside this if block, using one more if-else it is checked whether a > c, if this is so then a is greater else c is greater.

If the first if condition is false in the else block then else part of the inner if executes which means b > a. Inside this inner else one more if-else checks whether b > c, if it is so then b is greater else c is greater.

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群