LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Something Weird (https://www.linuxquestions.org/questions/programming-9/something-weird-264042/)

k1ll3r_x 12-08-2004 10:27 AM

Something Weird [ Java]
 
Code:

import java.io.*;
public class class1{
public static void main
(String args [])
{
String s = "UIL STATE 2004";
String [] t = s.split("[AEIOU]");
System.out.println(t[2]);
System.out.println(t.length);
}
}

im getting pretty confussed about this, when i put a lil space in the
Quote:

String [] t = s.split("[AEIOU]");
and make it look like this
Quote:

String [] t = s.split;(" [AEIOU] ")
then i get a total different answer, and im wondering why, im suppossed to get L*ST (if space where to be considered the *)
and for the second one i should be getting a five which i am, but, only if the space inside the quotations is removed, would someone plz help me, by explaning me a little bit more about this, thank you.

k1ll3r_x 12-08-2004 10:52 AM

ok ive been observing this program a little closer, and what its doing, its that it counts the first 2 spaces, and the ones after do not appear, nor count, and id like to ask why its doing that, plz again if someone could help, id really appreciate


All times are GMT -5. The time now is 11:57 AM.