将单个字符转换为CharSequence的最有效方法 [英] Most efficient way to convert a single char to a CharSequence

查看:198
本文介绍了将单个字符转换为CharSequence的最有效方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将单个char传递给需要CharSequence的方法的最有效方法是什么?

What's the most efficient way to pass a single char to a method expecting a CharSequence?

这就是我所拥有的:

textView.setText(new String(new char[] {c} ));

根据此处给出的答案,这是明智的选择输入是字符数组的情况下的处理方法.我想知道在单字符情况下是否可以使用偷偷摸摸的快捷方式.

According to the answers given here, this is a sensible way of doing it where the input is a character array. I was wondering if there was a sneaky shortcut I could apply in the single-char case.

推荐答案

textView.setText(String.valueOf(c))

这篇关于将单个字符转换为CharSequence的最有效方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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