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()");}}
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: