day03-if语句-格式1说明和使用

This commit is contained in:
2026-07-16 13:48:45 +08:00
parent 3eb476108e
commit eebe57bc08

View 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);
}
}
}