package com
.mtons
.mblog
;
import java
.lang
.reflect
.Field
;
public class FinalTest {
private final double a
;
{
Class
<FinalTest> aClass
= FinalTest
.class;
Field field
= null
;
try {
field
= aClass
.getDeclaredField("a");
field
.setAccessible(true);
Object o
= field
.get(this);
System
.err
.println(o
);
} catch (NoSuchFieldException | IllegalAccessException e
) {
e
.printStackTrace();
}
}
public FinalTest() {
this.a
= 10.0;
}
public static void main(String
[] args
) throws Exception
{
FinalTest test
= new FinalTest();
System
.out
.println(test
.a
);
}
}
转载请注明原文地址:https://tech.qufami.com/read-9405.html