开发者

Divide a string in java

开发者 https://www.devze.com 2022-12-22 01:27 出处:网络
I have a sti开发者_运维问答ng like this \"hello\" -- I want to divide the characters into h,e,l,l,o

I have a sti开发者_运维问答ng like this "hello" -- I want to divide the characters into h,e,l,l,o

How can I do this in Java? By using StringTokenizer? Any other suggestions?


How about String.toCharArray() ?


Why do you need to use the StringTokenizer?

I would read the String API for a method that allows you to get a character from the String.


Use this code

 

String str = "testing";
String [] temp = null;
temp = str.split("");
for (int i = 0 ; i < temp.length ; i++) {
        System.out.println(temp[i]);
           }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号