mardi 31 décembre 2019

Suggest me to find best programming/code practice in JAVA

I want to find out some coding tips to improve my code style and formats.

for example we are using ternary instead of if-else conditions just like.

With if-else condition.

String name = "Meet";
String desc;
if(name == null){
    desc = "Hello Guest";
} else {
    desc = "Hello " + name;
}

With ternary operator

String name = "Meet";
String desc = "Hello " + ((null == name) ? "Guest" : name);

Aucun commentaire:

Enregistrer un commentaire