有没有办法把一个 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.langjava.util中的Java Collection框架java.langjava.util它还有助于通过教程更慢地介绍 API.
It also helps to get introduced to the API more slowly through tutorials.
这篇关于在 Java 中,如何将 String 转换为 char 或将 char 转换为 String?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
“Char 不能被取消引用"错误quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用错误)
Java Switch 语句 - 是“或"/“和"可能的?Java Switch Statement - Is quot;orquot;/quot;andquot; possible?(Java Switch 语句 - 是“或/“和可能的?)
Java替换字符串特定位置的字符?Java Replace Character At Specific Position Of String?(Java替换字符串特定位置的字符?)
具有 int 和 char 操作数的三元表达式的类型是什么What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作数的三元表达式的类型是什么?)
读取文本文件并存储出现的每个字符Read a text file and store every single character occurrence(读取文本文件并存储出现的每个字符)
为什么我需要在 byte 和 short 上显式转换 char 原语Why do I need to explicitly cast char primitives on byte and short?(为什么我需要在 byte 和 short 上显式转换 char 原语?)