public class TestString {
public static void main(String[] args) {
String str = "AaaaABBBBcc&^%adfsfdCCOOkk99876 _haHA";
String[] upStr = str.split("[a-z0-9&^% _]");
System.out.println("Printout uppercase");
for (String outUp : upStr){
System.out.print(outUp);
}
System.out.println("\n" + upStr.length);
The "length" is wrong, so, where does the value comes from? How could we get real length?
System.out.println("\n Printout lowercase");
String[] lowStr = str.split("[A-Z0-9&^% _]");
for (String outLow : lowStr){
System.out.print(outLow);
}
System.out.println("\n" + lowStr.length);
System.out.println("\n non-English");
String[] nonEng = str.split("[A-Za-z]");
for (String outNonEng : nonEng){
System.out.print(outNonEng);
}
System.out.println("\n" + nonEng.length);
So my question is:
- The value of the length is incorrect, but where is is comes from?
- How could I get correct length of
String[]
?