devxlogo

Static Class Values Are Valid Even Without a Main Method

Static Class Values Are Valid Even Without a Main Method

Static fields have class-level scope, so they can execute even without a main() method. Here’s an example:

public class Static{     static{System.out.println("I will print without main()");}}

devx-admin

Share the Post: