View Single Post
Old 07-07-2012, 05:33 PM   PM User | #6
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,653
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Doesn't matter if they come from the scanner or from hard coded input. The split works as anticipated:
PHP Code:
        Scanner s = new Scanner(System.in);
        
String a s.nextLine();
        
String[] a.split(" ");

        
System.out.println("Chars in a:");
        
char[] ca a.toCharArray();
        for (
Character c ca)
        {
            
System.out.println((int)c);
        }
        
        
System.out.println("Chars in position 0:");
        
char[] c0 b[0].toCharArray();
        for (
Character c c0)
        {
            
System.out.println((int)c);
        }
        
        
System.out.println("Chars in position 1:");
        
char[] c1 b[1].toCharArray();
        for (
Character c c1)
        {
            
System.out.println((int)c);
        } 
Terminal:
Code:
some phrase
Chars in a:
115
111
109
101
32
112
104
114
97
115
101
Chars in position 0:
115
111
109
101
Chars in position 1:
112
104
114
97
115
101
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
sorlaker (07-07-2012)