1 19 20 import java.util.Vector ; 21 22 public class MethodScopedClass { 23 int var = 3; 24 25 public void test1() { 26 final long longVar = 5; 27 final int intVar = var; 28 final double dblVar = 3; 29 30 final float fooFloat = 5; 31 final float barFloat = 7; 32 33 class Hello { 34 int var = (int) longVar; 35 36 { 37 System.err.println("all constructors"); 38 } 39 40 Hello(float f, String info) { 41 System.err.println("construct: "+info+" "+f); 42 } 43 44 Hello(float f) { 45 this(f, "default"); 46 } 47 48 public void hello() { 49 System.err.println("HelloWorld: "+dblVar+" "+intVar); 50 } 51 }; 52 53 58 class foo { 59 foo() { 60 new Hello(fooFloat); 61 } 62 } 63 64 class bar { 65 bar() { 66 new Hello(barFloat, "bar"); 67 } 68 } 69 70 new foo(); 71 new bar(); 72 } 73 74 79 81 84 88 92 97 102 110 112 121 } 125 | Popular Tags |