java多种选择输出

xiaoxiao2022-06-11  30

java入门学习-----第一篇(java多种选择输出)

Java中有多个if语句时,满足的条件都会执行。 具体看代码如下:

package testOne1; /** * */ /** * @author AnnLee *10.23 */ public class tuesday { public static void main(String[] args) { int x=14; if(x<=15) { System.out.println("2"); } if(x<=20) { System.out.println("1"); } } }

最后输出

2 1

当java满足多个条件,会输出每一个,按从上到下的顺序依次执行。 希望对你有帮助

转载请注明原文地址: https://www.6miu.com/read-4930293.html

最新回复(0)