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("程序结束"); + } + +} + +