分析程序的输出
来源:互联网 发布:mac 输入法切换 编辑:程序博客网 时间:2024/06/01 09:24
写出下面代码的输出结果,为什么?
public class Test2{ static int i=5; public static void main(String[] args){ Father father = new Child(); father = new Child(); System.out.println( (change()==3)?i+15:i+10.0 ); } public static int change(){ if(i==5){ i = i+10; } return i = i/5; }}class Father{ public Father(){ System.out.println("father..."); } static{ System.out.println("father2"); }}class Child extends Father{ public Child(){ System.out.println("child..."); } static{ System.out.println("child2"); }}/*输出结果:father2child2father...child...father...child...18.0*//* ?号表达式中,冒号两边的表达式的数据类型必须一致 (若不同则自动向高精度靠齐) int x=3,y=1; System.out.println( (x==3)?y+1:y+10 ); //结果:2 System.out.println( (x==3)?y+1:y+10.0 ); //结果:2.0*/
阅读全文
0 0
- 分析程序的输出
- 133.分析一下这段程序的输出
- 该程序的输出
- 程序的输出
- tcpdump的输出分析
- tcpdump的输出分析
- tcpdump的输出分析
- [汇编笔记]一个接受输入的字符串并反向输出的程序分析
- PHP-FPM,加速文件上传和输出,分析PHP程序慢的瓶颈
- 用移位运算实现一个整数二进制形式的输出--简短程序分析
- 看看程序的输出结果
- 程序的输入和输出
- 加快php程序的输出
- 获取命令行程序的输出
- WindowsGUI程序的终端输出
- 输出星号图的程序
- 输出移动小人的程序
- 输出它本身的Java程序
- Java集合的Stack、Queue、Map的遍历
- 常见异常类型
- NAT工作原理
- 自定义控件的三个构造方法含义
- Linux 用户管理命令
- 分析程序的输出
- linux文件目录结构以及常用命令
- svg相关知识简介
- 算法马拉松28 先序遍历与后序遍历
- java每日一练
- 四、高级文件I/O
- Java™ Platform, Standard Edition 8 API Specification
- 长沙理工第12届ACM大赛 L-选择困难症(折半枚举+二分)
- 持久层dao设计模式