下面代码中包含一些自动装箱和自动拆箱的行,其中自动装箱的行有:
1. public class UseBoxing{
2. boolean go(Integer i){
3. Boolean ifSo = true;
4. Short s = 300;
5. if(ifSo){
6. System.out.println(++s);
7. }
8. return !ifSo;
9. }
10. public static void main(String[] args){
11. UseBoxing ub = new UseBoxing();
12. ub.go(20);
13. }
14. }
1. public class UseBoxing{
2. boolean go(Integer i){
3. Boolean ifSo = true;
4. Short s = 300;
5. if(ifSo){
6. System.out.println(++s);
7. }
8. return !ifSo;
9. }
10. public static void main(String[] args){
11. UseBoxing ub = new UseBoxing();
12. ub.go(20);
13. }
14. }
举一反三
- 以下代码的调试结果为?1: public class Q102: {3: public static void main(String[] args)4: {5: int i = 10;6: int j = 10;7: boolean b = false;8:9: if( b = i == j)10: System.out.println("True");11: else12: System.out.println("False");13: }14: }
- Given: 1. public class Foo implements Runnable { 2. public void run (Thread t) { 3. System.out.println("Running."); 4. } 5. public static void main (String[] args) { 6. new Thread (new Foo()).start(); 7. } 8. } What is the result?
- 关于以下程序的说明,正确的是()1. class StaticStuff2. {3. static int x=10;4. static { x+=5;}5. public static void main(String args[ ])6. {7. System.out.println("x=" + x);8. }9. static { x/=3;}10. }
- 关于以下程序代码的说明正确的是 1. class HasStatic{ 2. private static int x=100; 3. public static void main(String[ ] args){ 4. HasStatic hs1=new HasStatic; 5. hs1.x++; 6. HasStatic hs2=new HasStatic; 7. hs2.x++; 8. hs1=new HasStatic; 9. hs1.x++; 10. HasStatic.x--; 11. System.out.println(“x=”+x); 12. } 13. }
- 以下程序的运行结果为: 1. public class Conditional { 2. public static void main(String args [] ) { 3. int x = 4; 4. System.out.println( "value is " + 5. ((x > 4) ? 99.99 : 9)); 6. } 7. }