Tricky Java programs

Look at the following code, please help me solve this problem

class TestTrick{

    public static void main(String args[])
    {

    }

    static marker()
    {

    System.out.println("programe executed");

    }

}

The desired result of the program is that the program should print the program execution, which means that the marking method should be executed But there are some rules:

>Neither of these methods should be written. > No other classes can be added to this program. > The program must execute the output statement in the marker method

This is three days. I can't solve the problem because I'm not a java programmer I've searched all the content on the Internet for clues, but I failed Please help me to run this program strictly according to the rules

Solution

I think what they are looking for is static initializer

static {
    marker();
}

This runs when the class is loaded

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>