What is the better way to design variables?

Should i format variables like this:

String type = null;
String name = null;
int age = 0;
double weight = 0;
boolean isFly;
boolean isWalk;
boolean isSwim;

Or like this:

String type = null, name = null;
int age = 0;
double weight = 0;
boolean isFly, isWalk, isSwim;

And may you give me any article about code formatting in java? Thanks for help!

>Solution :

As a professional Java developer I have always made variables like this:

String name = "Vitaly";

In my opinion it is the best way because it is easy to read and understand. However, there is no real functional difference so it is up to you. Hope this helps!

Leave a Reply