From e35b8e59338f4da862757b65e8103606fb518076 Mon Sep 17 00:00:00 2001 From: xuxin <840198532@qq.com> Date: Wed, 14 Jan 2026 15:55:24 +0800 Subject: [PATCH] =?UTF-8?q?day03-=E6=B5=81=E7=A8=8B=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E8=AF=AD=E5=8F=A5-=E5=88=A4=E6=96=AD=E6=B5=81=E7=A8=8B-if?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day03/src/com/inmind/if01/Demo01.java | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 day03/src/com/inmind/if01/Demo01.java diff --git a/day03/src/com/inmind/if01/Demo01.java b/day03/src/com/inmind/if01/Demo01.java new file mode 100644 index 0000000..fc1c66a --- /dev/null +++ b/day03/src/com/inmind/if01/Demo01.java @@ -0,0 +1,43 @@ +package com.inmind.if01; +/* +if格式一: + +if(判断条件){ + 语句; +} + +执行顺序:先执行判断条件,判断条件必须是布尔型的结果, + 如果为true,就执行大括号内部的语句,false就直接跳过大括号中的内容 +*/ +public class Demo01 { + + + public static void main(String[] args) { + //请大家使用if格式一,打印出哪个整数变量大 + int a = 10; + int b = 20; + if(a > b){ + System.out.println("变量a的值大,为"+a); + } + + if(b > a){ + System.out.println("变量b的值大,为"+b); + } + System.out.println("程序结束"); + + } + + //抽取为一个if的格式一的方法 + public static void ifMethod1() { + int i = 100; + //如果i的值大于10,我就打印一次helloworld,如果不满足条件则不打印 + if(i > 10){ + System.out.println("helloworld"); + } + + System.out.println("程序结束"); + } + +} + +