package com.dengwen;
public class X {
public static void main(String []args){
m();
}
public static void m() {
float f=3.14f;
Float o = new Float(3.14f);//Float o = new Float(3.14);这是正确的
Object[] oa = new Object[1];
oa[0] = o;
o = null; //此时对象o 是不会被回收的, 因为oa还指向他
oa[0] = null;// 到此处是对象o会被回收, 因为再也没有对象指向o了
System.out.println(oa[0]);
}
}
package com.dengwen1;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
interface Person {
String name="lidengwen";
int age=22;
Integer k = 0; //等价于public static final int k=0;
void say();
}
public class Y {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Class c=Class.forName("com.dengwen1.Person");
// System.out.println(c.getName());
Field[] fs=c.getDeclaredFields();//得到所有字段
for (int i = 0; i < fs.length; i++) {
Class c1=fs[i].getType();
int m=c1.getModifiers();
String s=Modifier.toString(m);
System.out.println("moddfier:"+s); ;
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
package com.dengwen1;
public class Z {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
float foo= -1;
//float foo2=1.0; 错误, 默认为double, double无法转型到float
//float foo3=42e1; 错误, 默认为double, double无法转型到float
float foo4=2.02f;
//float foo5=3.03d; 错误, 默认为double, double无法转型到float
float foo6=0x0123;
System.out.println(foo6);
System.out.println(1*Math.pow(16, 2)+2*Math.pow(16, 1)+3*Math.pow(16, 0));
}
public void run(){}
}
没有评论:
发表评论