
Java流程控制:选择结构
发布日期:2021-05-15 03:50:09
浏览次数:15
分类:博客文章
本文共 5259 字,大约阅读时间需要 17 分钟。
������������������
- ������������������������������������������������������������������������������������������
- Java������������������������������������'if...else'���������'switch...case'���������
- Java������������������������������������������������������������������������������������������������������������
������'if...else'������
���������'if'���������������������'else'���������������������Java���������'if...else'���������������������������������
���������
- 'if'���������������
- 'if'���������������
- 'if'���������������
������'if'���������������
���������
if(/* ��������������� */){ /* ������������������������true������������������ */}
���������
- ������'if'������������������������������������������������������������
- ������������������������������'true'������������'if'������������������������������������'if'���������������������������
���������
/* ���������������������������������������if������ */public static void main(String args[]){ int x = 10; if(x < 20){ System.out.print("������if������"); }}
������'if'���������������
���������
if(/* ��������������� */){ /* ������������������������������true������������������ */}else{ /* ������������������������������false������������������ */}
���������
- 'if'���������������������'else'������������'if'������������������������������'false'������'else'������������������������
���������
/* ���������������������������������������else������ */public static void main(String args[]){ int x = 30; if(x < 20){ System.out.print("������if������"); }else{ System.out.print("������else������"); }}
������'if'���������������
���������
if(/* ���������������1 */){ /* ���������������������1���������true��������������������� */}else if(/* ���������������2 */){ /* ���������������������1���������false���������������������2���������true��������������������� */}else if(/* ���������������3 */){ /* ���������������������1������������������2������������false���������������������3���������true��������������������� */}else{ /* ���������������������1������������������2������������������3������������false��������������������� */}
���������
- 'if'���������������������'else if���else'���������������'else if'������������������������������������������������������������������������������
���������
- 'if'��������������� 1 ���'else'���������'else'������������������'else if'���������������
- 'if'������������������������'else if'������������������������'else'���������������
- ������������������'else if'���������'if'���������������true������������'else if'������'else'���������������������������
���������
/* ������������������������������������������������if else������ */public static void main(String args[]){ int x = 30; if(x < 20){ System.out.print("������if������"); }else if(x < 30){ System.out.print("������if else������"); }else if(x < 40){ System.out.print("���������������if else������"); }else{ System.out.print("������else������"); }}
������'switch'���������������
���������
switch(variable){ case value1: /* ������������������value1��������������������������� */ break;/* break������������������ */ case value2: /* ������������������value2��������������������������� */ break; case value3: /* ������������������value3��������������������������� */ break; default:/* default������������������ */ /* ������������������value1���value2���value3������������������������������ */}
���������
- 'switch...case'������������������������������������������������������������������������������������������������
���������
- 'switch...case'���������������������������������byte���short���int���char������JavaSE7���������'switch...case'������������String������������������case���������������������������������������������
- 'switch'������������������������'case'���������������'case'������������������������������������������'case'���������������������������������������������������������������������������������������������������������������
- ������������������'case'������������������������������'case'������������������������������������������'break'������������������������'switch'���������������'switch'���������������������������
- 'case'���������������������������'break'���������������������'break'���������������������������������������������'case'���������������������'break'���������
- 'case'���������������������������������
- 'switch'������������������������'default'���������������������������������'switch'������������������������������������������������������������������������������������'default'���������'case'������������������������������������������������'default'���������������'break'���������
- 'switch...case'������������������������������������������������������������������������������������������������������������'break'������������������������������������������������������������������������������'switch...case'���������
���������
/* ���������������������������������������1 2 3 */public static void main(String args[]){ int i = 1; switch(i){ case 0: System.out.println("0"); case 1: System.out.println("1"); case 2: System.out.println("2"); case 3: System.out.println("3"); break; default: System.out.println("default"); }}
发表评论
最新留言
表示我来过!
[***.240.166.169]2025年05月02日 19时09分35秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
什么是5G?居然有人用漫画把它讲得如此接地气!
2021-05-15
Spring cloud --分布式配置中心组件Spring Cloud Config
2021-05-15
UE4接入Android第三方库2——通过JIN与GameActivity通信
2021-05-15
Unity Job System 2——并行处理数据
2021-05-15
spark概述
2021-05-15
JavaScript 知识梳理[一] 变量类型,浅拷贝,深拷贝
2021-05-15
pip命令 failed to create process.
2021-05-15
做SMTP客户端遇报错:535 Error
2021-05-15
Python3的修改
2021-05-15
SQL基础学习(六)- MySQL的insert语句
2021-05-15
Linux kernel pwn --- CSAW2015 StringIPC
2021-05-15
2020 05 02 记录思考
2021-05-15
2020-05-31 py执行时超时控制
2021-05-15
一段强大的shellcode
2021-05-15
双链表相加问题
2021-05-15
GB2312-80 汉字机内码
2021-05-15
n的a进制数
2021-05-15
配置jdk的环境变量
2021-05-15
echo命令的颜色及同行显示控制
2021-05-15