如何将字符串转换为包含每一个字符串数组 [英] How to convert a String into an array of Strings containing one character each

查看:103
本文介绍了如何将字符串转换为包含每一个字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题需要这儿过得从控制台读取字符串转换成字符串的每个字符。例如字符串:aabbab我想这个字符串转换成string.How数组我要这么做?


解决方案

 的String []结果= input.split((^)?!);

这是用来做什么的分裂是不是由字符串开头pceded $ P $所有空字符串输入字符串。

I have a small problem here.I need to convert a string read from console into each character of string. For example string: "aabbab" I want to this string into array of string.How would I do that?

解决方案

String[] result = input.split("(?!^)");

What this does is split the input String on all empty Strings that are not preceded by the beginning of the String.

这篇关于如何将字符串转换为包含每一个字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆