Java??????????????????????
??????????? ???????[ 2016/7/20 10:30:22 ] ??????????????? ????
????/*???????????????????????????????????????????????У?
????1 ?????????????????(????????У???????????)
????2 ?????????????????(?????????????У??????????????)
????3 ????????(??????????????2??????й??????????????????public????private)
*/
public class Test{
public Test(){
System.out.println("??Test??????????? 6");
}
{
System.out.println("??Test???????鱻??? 4"); //????????
}
private TestInstance ti = new TestInstance(); //???????
private static TestInstance ti1 = new TestInstance(2); //???????
static{
System.out.println("??Test???????鱻??? 3"); //????????
}
public static void main(String[] args){
//??????????????????? 1 2 3
//????????????????? 1 2 3 4 5 6
new Test();
}
}
class TestInstance{
public TestInstance(){
System.out.println("??TestInstance????????????? 5");
}
static{
System.out.println("??TestInstance??????о??????? 1");
}
public TestInstance(int i){
System.out.println("??TestInstance????????????? 2");
}
}
public class TestStaticCode {
/*???????????????????????????????????????????????У?
1 ?????????????????(?????????)
2 ?????????????????(????????????)
3 ????????(??????????????2??????й??????????????????public????private)
*/
//?????????0 1 2 3 4
//??????????????иt侲?????(?????t???????????????????????)??????????????????????????????????
//????侲??????????????????о???????
private static TestStaticCode tsc = new TestStaticCode();
static{
System.out.println("4");
}
{
System.out.println("0");
}
private InstanceVariable iv = new InstanceVariable();
//????е??????
private TestStaticCode(){
System.out.println("3");
}
public static void main(String[] args){
}
}
class InstanceVariable {
static{
System.out.println("1");
}
public InstanceVariable(){
System.out.println("2");
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11