海大软件1102班 - 云代码空间
—— 你究竟输入什么了导致它崩溃?
public class TestString { public static void link(String a){ a+="World"; } public static void main(String []args){ String a = "Hello"; link(a); System.out.println(a); } }
System.out.println("ja"+"va" == "java");
final String str = "java"; System.out.println(str=="java")
public class Parent { //1 static int a = 1; //2 static { a=10; System.out.println("parent static code"); } //4 public Parent(){ System.out.println("Parent constructor"); System.out.println("Parent a ="+a); } public static void main(String []args){ System.out.println("*****************"); Parent c = new Child(); } } public class Child extends Parent{ static int a = 2; //3 static { a=20; System.out.println("child static code"); } public Child(){ System.out.println("Child constructor"); System.out.println("Child var a="+a); } }
public class OuterClass { static int a; int b; private class InnerClass{ public InnerClass(){ System.out.println("InnerClass create:"+a); } } public OuterClass(){ InnerClass ic = new InnerClass(); System.out.println("OuterClass create"); } public static void main(String []args){ OuterClass oc = new OuterClass(); } }
public class TestFloat { public static void main(String []args){ Float a = new Float(3.4); System.out.println(a.SIZE); a = new Float(34000); System.out.println(a.SIZE); } }
public static final int SIZE The number of bits used to represent a float value.
意思是说:通常去描述一个float值的位数.
这个是一个常量,来看看源码吧:
public class Test2 { public static void main(String[] args) { float a = 3.4; } }
public class Test2 { public static void main(String[] args) { Float a = new Float(3.4); } }
public Float(double value) { this.value = (float)value; }
a: Stirng a ="Gone With Wind"; String t= "Wind"; String m; m=a-t; B: Stirng a ="Gone With Wind"; String m ; m=a[3]+"one"; C: Stirng a ="Gone With Wind"; Sting m; m=a.toUpperCase(); D: 不记得了
public class A { //3 public A(){ a1(); } public void a1(){ System.out.println("A-a1"); } } public class B extends A{ int bb = 0; //2 public B(){ //5 bb=1000; } //4 public void a1(){ System.out.println("bb is"+bb); System.out.println("B-a1"); } public static void main(String []args){ new B(); } }