space replace problem
in
Programming Questions
•
1 year ago
If i try " 07" it prints nothing, if i try "07" it prints '0'.
Why is the space in front needed?
Why is the space in front needed?
- String date = " 07";
//String date = "07";
for (int i = 31; i >= 1; i--) {
String d = nfs(i, 2);
if (date.contains(d)) {
date = date.replace(d, "");
break;
}
// check for 1 digit
d = ""+i;
if (date.contains(d)) {
date = date.replace(d, "");
break;
}
}
println(date);
1