将关联的字符(来自 ASCII)放入对象类型列表中
我希望放入关联的字符(例如,如果整数是 97,我想将小写的“a”放入 ArrayList)
到目前为止我一直在尝试:
char[] myChar = Character.toChars(integerArray.get(i));;
System.out.println(myChar);
puzzleObjRow.add(myChar);
当我打印它时,它会打印字符我想要,但是当我添加它时,我只是得到随机数/符号等(只是在内存中或诸如此类的东西)
是否有办法将其类型转换为单个字符? (而不是数组?)或者什么是可能的解决方案
感谢您的帮助
I am looking to put in the associated char (for example, if the integer is 97, I want to place a lower case 'a' into an ArrayList)
What I have been trying thus far:
char[] myChar = Character.toChars(integerArray.get(i));;
System.out.println(myChar);
puzzleObjRow.add(myChar);
when I print it it prints the char I want, but when I add it I just get the random numbers/symbols etc (that were just in the memory or whatnot)
Is there anyway to typecast this to just a single char? (and not an array?) or what is a possible solution
thanks for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我猜对了,您可以将数组中的第一个元素分配给一个字符:(
回答评论)您也可以这样做:
If I get you right, you can just assign the first element in the array to a char:
(answering the comment) You may also do: