Execute something before initializing static variables

I am developing a Java application using SWT on mac.The application shows SWT as its name and I wanted to change it. I saw this SWT on OS X: change the application name and wanted to use it Display.setAppName()

, but it has to be used before I initialize any display as per the answer. Unfortunately, I have declared my Display variable as static, which will be initialized at the beginning of the application. How and where I put this code so that it is executed first before initializing static variables.

+3


source to share


1 answer


You can put them in blocks static

that are executed first.

static{
Display.setAppName()
}

      



See In what order are static and initialization blocks executed when using inheritance? to find out more

+2


source







All Articles