Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

What's rong wiht String.split(".")?

807601Jan 22 2008 — edited Jan 22 2008
Hi all
I have two similar code below:
public class Test {

    public static void main(String[] args) {
        String ip  = "192,168,30,153";//comma
        
        String[] ss = ip.split(",");   //it's comma
        for(String s:ss){
        	System.out.println(s);
        }
     }
}
the result is :
192
168
30
153

but when it changs to period nothing printed.
public class Test {

    public static void main(String[] args) {
        String ip  = "192.168.30.153";//period
        
        String[] ss = ip.split(".");   //it's period
        for(String s:ss){
        	System.out.println(s);
        }
     }
}
thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 19 2008
Added on Jan 22 2008
2 comments
199 views