有没有办法把一个 char
变成一个 String
或一个带有一个字母的 String
变成一个 char
(例如如何将 int
转换为 double
并将 double
转换为 int
)?(如果可以,请链接到相关文档).
Is there a way to turn a char
into a String
or a String
with one letter into a char
(like how you can turn an int
into a double
and a double
into an int
)? (please link to the relevant documentation if you can).
我如何才能找到我在文档中只是模糊地知道的类似内容?
How do I go about finding something like this that I'm only vaguely aware of in the documentation?
char firstLetter = someString.charAt(0);
String oneLetter = String.valueOf(someChar);
您可以通过识别可能涉及的类来查找文档.在这里,候选是 java.lang.String
和 java.lang.Character
.
You find the documentation by identifying the classes likely to be involved. Here, candidates are java.lang.String
and java.lang.Character
.
您应该首先熟悉:
java.lang
java.util
中的Java Collection框架java.lang
java.util
它还有助于通过教程更慢地介绍 API.
It also helps to get introduced to the API more slowly through tutorials.
这篇关于在 Java 中,如何将 String 转换为 char 或将 char 转换为 String?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!