Consider these 2 methods, both of which convert null strings to empty strings:
private static final
String N2E1(String str){
if (str == null){
str = "";
}
return str;
}
private static final String N2E2(String str){
return str == null ? "" : str;
}
Assuming it will be called a lot, is there a performance difference, or will the compiler just optimize N2E1 to do what N2E2 does anyway?
Thanks for your help!