如何从字符串中打印每个字符? [英] How to print each character from a string?

查看:82
本文介绍了如何从字符串中打印每个字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法一次从输入中读取单个字符并对其进行处理,而又不对词汇进行标记化?

Is there a way to read a single character at a time from the input and process it, without tokenizing the vocabulary?

推荐答案

字符串上的toCharArray()函数在这里可能会有用.

The toCharArray() function on Strings might be useful here.

for(char c : s.toCharArray())
     System.out.println(c);

并仅打印字符串中的小写字母-谢谢@fge

And to print only the lowercase ones in the string- Thanks @fge

for(Character c : s.toCharArray()){
        if(Character.isLowerCase(c))
        System.out.println(c);
}

这篇关于如何从字符串中打印每个字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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