Java Concept : No need to initialize boolean at class level

This concept says, boolean take the default value and does not required any pre-assignment if at class level
How ever if it is a local variable ie defined inside the method then compilation error for uninitialized variable might occur.

boolean

If we do like :

boolean var = false;

Then it reassign the same value in 2 steps and make is much more slower.

1. Assign default value (false) to variable. 

2. Assign user defined value to variable.

For better performance and clean code leave assignment to JVM Smile

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s