Files
javaSE-0113/day03/src/com/inmind/if01/Demo01.java

44 lines
1002 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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