I'm going to go crazy. Maybe this is the reason I work 12 hours .... but why my if statment will not evaluate true at startup if (band.equals("4384")? I type bandon the screen and it reads 4384, but it will not evaluate true. I use .equals () so many times with a problem, what am I doing wrong?
public class Test {
public static void main(String[] args) {
String endBand = " ";
String str = "SCELL: UARFCN 4384, Prim. SC: 362, RSCP: 70, EcNo: 44";
endBand = getBandNumber(str);
System.out.println("endBand is " + endBand);
}
private static String getBandNumber(String str) {
String band = " ";
int begin = 0, end = 0;
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (c == 'N' && str.charAt(i + 1) == ' ') {
begin = i + 1;
} else if (c == ',') {
end = i;
break;
}
}
band = str.substring(begin, end);
System.out.println("band is " + band);
if (band.equals("4384")) {
band = "5";
} else {
band = "2";
}
return band;
}
}
source
share