小编Kyl*_*yle的帖子

如何将≠符号插入字符串中

我想要的最终结果就是这个

System.out.println("This is the not equal to sign\n?");
Run Code Online (Sandbox Code Playgroud)

出现(运行时)为

This is the not equal to sign
?
Run Code Online (Sandbox Code Playgroud)

不要出现

This is the not equal to sign
?
Run Code Online (Sandbox Code Playgroud)

有没有办法做到这一点?我尝试使用Windows字符映射,在这里复制符号,并在我的代码中,但在将编码更改为UTF-8并插入后,它出现了?跑步的时候......
可以做些什么?提前感谢这个完全简单的问题的答案

java string utf-8 character-encoding

9
推荐指数
1
解决办法
170
查看次数

java中的字符串索引越界错误(charAt)

快问.我在程序中有这个代码:

input = JOptionPane.showInputDialog("Enter any word below")
int i = 0;  
for (int j = 0; j <= input.length(); j++)  
{
    System.out.print(input.charAt(i));  
    System.out.print(" "); //don't ask about this.  
    i++;
}   
Run Code Online (Sandbox Code Playgroud)
  • 输入是用户输入
  • i 是一个值为0的整数,如图所示

运行代码会产生此错误:

线程"main"中的异常java.lang.StringIndexOutOfBoundsException:字符串索引超出范围: 在program.main的
java.lang.String.charAt(未知源)
处为6 (program.java:15)

如果我charAt int改为0而不是i,它不会产生错误......
可以做什么?问题是什么?

java charat

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×2

character-encoding ×1

charat ×1

string ×1

utf-8 ×1