所以我想知道是否有一种方法可以将 alt 代码字符 (♥♣☺☻) 添加到 java 中的字符串中?
喜欢JOptionPane.showMessageDialog(null, "This is a heart: ♥");
最佳答案
你有什么问题?
JOptionPane.showMessageDialog(null, "This is a heart: ♥");
或者,您可以使用 ALT 代码的 Unicode 版本来显示它们:
JOptionPane.showMessageDialog(null, "I \u2665 you");
正如我们在 @Donald2000 的评论中看到的那样,使用 unicode 会是更好的选择
引用:
关于java - 在 Java 中使用替代代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13736244/