day03-if语句-格式1说明和使用
This commit is contained in:
35
day03/src/com/inmind/if01/Demo01.java
Normal file
35
day03/src/com/inmind/if01/Demo01.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.inmind.if01;
|
||||
/*
|
||||
if格式一:
|
||||
|
||||
if(判断条件){
|
||||
语句;
|
||||
}
|
||||
|
||||
执行顺序:先执行判断条件,判断条件必须是布尔型的结果,
|
||||
如果为true,就执行大括号内部的语句,false就直接跳过大括号中的内容
|
||||
*/
|
||||
public class Demo01 {
|
||||
public static void main(String[] args) {
|
||||
//定义整数变量
|
||||
int i = 10;
|
||||
if (i != 10) {
|
||||
System.out.println("i等于10");
|
||||
}
|
||||
|
||||
System.out.println("程序结束");
|
||||
System.out.println("-----------------");
|
||||
//判断2个值谁大
|
||||
int a = 10;
|
||||
int b = 20;
|
||||
if (a > b) {
|
||||
System.out.println("a的值大,值为:"+a);
|
||||
}
|
||||
|
||||
if (a < b) {
|
||||
System.out.println("b的值大,值为:"+b);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user