I have two same conditions and i want to know which is well in perfomance ?
if(str_final.charAt(str_final.length() -1) == 'a'
|| str_final.charAt(str_final.length() -1) == 'b' )
{
// body
}
——————–OR——————–
char temp = str_final.charAt(str_final.length() -1);
if( temp == 'a' || temp == 'b')
{
// body
}
Second option would be faster and also much more readable, however better to use some other name than ‘temp’