码迷,mamicode.com
首页 > 其他好文 > 详细

用if else 判断a ,b值大小 并输出最大值.

时间:2016-01-04 21:07:00      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:

 1 public class Exercise {
 2 
 3     public static void main(String[] args) {
 4         
 5         int a=7;
 6         
 7         int b=8;
 8         
 9         if(a>b)
10             
11         {
12             System.out.println("a是最大值"+a);
13         }    
14         
15         else if(a<b)
16             
17         {
18             System.out.println("b是最大值"+b);
19         }
20         
21         else
22             
23         {
24             System.out.println("a和b相等");
25         }
26 
27     }
28 
29 }

b是最大值8

用if else 判断a ,b值大小 并输出最大值.

标签:

原文地址:http://www.cnblogs.com/kingmin/p/5100219.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!