I created the code below to print out all of the values of a string to 'true' or 'false'. I would like to fill an array with all the printed values "True true false true...." Right now when I print out the values of the String str if it is not in the loop I only get the first value of the first character.
// First find out how many words and store in numWords
// Use "isDelim()" to determine delimiters versus words
//
// Create wordArr big enough to hold numWords Strings
// Fill up wordArr with words found in "phrase" parameter
public void Parse(String phrase) {
int len = phrase.length();
String str = null;
int isTrueCount = 0;
int isFalseCount = 0;
for (int i = 0; i < (len); i++) {
str = String.valueOf(!isDelim(phrase.charAt(i)));
System.out.println(str);
if (str == "true") {
isTrueCount++;
} else {
isFalseCount++;
}
}
System.out.println(isTrueCount);
System.out.println(isFalseCount);
}
Length of len is any arbitrary string/text file/keyboard input. I am hoping to use the true and false values within an array to pick out the true number of words from delims.
str += String.valueOf(foo) + " ";. Better still, don't create a String at all, but add the results into anArrayList<Boolean>.