Initialize member variables in the beginning of class definition or in constructor?

In your example, the only difference is when they are initialized. According to the JLS, instance variables are initialized before the constructor is called. This can become interesting when you have super classes to deal with, as the initialization order isn’t always so obvious. With that, keep in mind “super” instance variables will still be initialized when no explicit super constructor is called.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)