lundi 26 mars 2018

multiply if statements vs. collection.contains

Which way better?

if (name.equals("Pablo") || name.equals("Marko') || .. ); 

or

if (Sets.newHashSet("Pablo", "Marko", ..).contains(name));

Interest about memory using, performance, readabilty

Aucun commentaire:

Enregistrer un commentaire