Firstly your substring
bounds are faulty. 0, 0
means 0 length string. That will not get you first character. You should use 0, 1
. And then use equals()
method for String comparison:
if (orari[i].substring(0,1).equals("0"))
Also, you can avoid that substring
in if
condition by using charAt()
method:
if (orari[i].charAt(0) == '0')