static variable can't be defined inside any method (even if the method is static) you can however define the static variable outside the constructor and assign a value inside the constructor. But by doing so the variable will then be accessible to the whole class.