Can I combine two CharSequence variables like this?
if (status == 1) {
for (int i = 0; i < get.length(); i++) {
if (get.charAt(i) == ')') {
} else {
temp = temp.toString() + get.charAt(i);
// temp and get are charSequence VARIABLES
}
}
}
Syntax is looking OK as no errors from compiler, but the app is crashing.
Also I don't want to get in List and ArrayList items at this beginner stage. Any idea what I am doing wrong?
Also if you say that I shouldn't use .toString() method then I understand but what should I do then to make it correct?
Well first you can think about refactoring code a little:
if (status == 1) {
for (int i = 0; i < get.length(); i++) {
if (!(get.charAt(i) == ')')) {
temp += get.charAt(i);
}
}
}
The error you are encountering is in the different place of your code. This one cant throw an exception.
Also for parsing, you should think about regular expressions:
String tryThis = temp.replaceAll("\\)", "");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With