String are immutable in Java. You can't change them.

You need to create a new string with the character replaced.

String myName = "domanokz";
String newName = myName.substring(0,4)+'x'+myName.substring(5);

or you can use a StringBuilder:

StringBuilder myName = new StringBuilder("domanokz");
myName.setCharAt(4, 'x'); System.out.println(myName);

http://stackoverflow.com/questions/6952363/java-replace-a-character-at-a-specific-index-in-a-string

Java - replace a character at a specific index in a string?的更多相关文章

  1. java.lang.IllegalArgumentException: Illegal character in query at index 261

    在BaseFragment中使用了LoadingPage,而LoadingPage的联网加载使用的是AsyncHttpClient.一直报java.lang.IllegalArgumentExcept ...

  2. 爬取数据时解析url时一直报错Caused by: java.net.URISyntaxException: Illegal character in query at index 823替换了所有空格和特殊字符还是无效

    近日在用HttpClient访问抓取汇率时,为了省力,直接采用 String url = "http://api.liqwei.com/currency/?exchange=usd|cny& ...

  3. java.lang.IllegalArgumentException: Illegal character in query at index ...解决办法

    今天在写智能机器人问答实现的时候遇到了一个问题,就是我发送消息不能输入空格 给我报了一个错误java.lang.IllegalArgumentException: Illegal character ...

  4. HTTP错误:java.lang.IllegalArgumentException: Illegal character in scheme at index 0: http://xxxxxx

    读取T卡文件里的域名,HTTP请求出现如下错误 java.lang.IllegalArgumentException: Illegal character in scheme at index 0: ...

  5. Exception in thread "main" java.lang.IllegalArgumentException: Illegal character in query at index 189......

    Exception in thread "main" java.lang.IllegalArgumentException: Illegal character in query ...

  6. 腾讯云 activeMQ Illegal character in hostname at index 7

    查找问题步骤: 1.  /usr/local/apache-activemq-5.9.1/data/activemq.log 看一下这个.log后缀的启动日志,可以将它下载下来再看. 先尝试修改配置文 ...

  7. activemq启动闪退/失败 (Illegal character in hostname at index 5: ws://****:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600)

    java.net.URISyntaxException: Illegal character in hostname at index 5: ws://****:61614?maximumConnec ...

  8. Java replace() 方法

    Java replace() 方法 Java String类 replace() 方法通过用 newChar 字符替换字符串中出现的所有 oldChar 字符,并返回替换后的新字符串. 语法 publ ...

  9. 字符串replaceAll()方法报错:java.util.regex.PatternSyntaxException:Unclosed group near index...

    Unclosed group near index错误 之前自己写的一个模块在项目上线后最近频频出现tomcat崩掉的情况,从log看出现如下的报错信息: java.util.regex.Patter ...

随机推荐

  1. Kafka错误“Network is unreachable”和“larger than available brokers”

    确定Kafka安装和启动正确,ZooKeeper可以查到所有的Brokers,但执行: kafka-topics.sh --create --zookeeper localhost:2181 --re ...

  2. MIT Molecular Biology 笔记7 调控RNA

    视频  https://www.bilibili.com/video/av7973580/ 教材 Molecular biology of the gene 7th edition  J.D. Wat ...

  3. Shell编程-11-子Shell和Shell嵌套

    目录 什么是子Shell 子Shell产生的途径 Shell脚本调用模式 什么是子Shell     子Shell的概念其实是贯穿整个Shell的,如果想要更好的理解和写Shell脚本则必须要了解子S ...

  4. kepware http接口 nodejs开发

    读取某变量的值(native var http = require("http"); var options = { "method": "GET&q ...

  5. noip第6课作业

    1.    数据统计 [问题描述] 输入N个整数,求出它们的最小值.最大值和平均值(保留3位小数).输入保证这些数都是不超过1000的整数.(1<=N<=1000) [样例输入] 8 2 ...

  6. Django URLs error: view must be a callable or a list/tuple in the case of include()

    Django 1.10 no longer allows you to specify views as a string (e.g. 'myapp.views.home') in your URL ...

  7. 把EXE可执行文件等作为资源包含在Delphi编译文件中

    摘自我自己过去写的一段心得. 1.编辑资源文件 *.RCWave: 资源文件是声音文件:RCDATA: 二进制数据AVI: AVI动画:ICON: 图标文件:BITMAP: 位图文件:CURSOR: ...

  8. Windows10卡顿,磁盘 内存占用100%或比较多

    1.关闭服务:Superfetch: 2.结束antimalware service executable进程,gpedit.msc下依次点击“计算机配置/管理模板/Windows组件/Windows ...

  9. 等到花儿也谢了的await

    async/task/await三组合是.NET Framework 4.5带给.NET开发者的大礼,合理地使用它,可以提高应用程序的吞吐能力. 但是它的使用有点绕人,如果不正确使用,会带来意想不到的 ...

  10. 创建窗口句柄时出错(error creating window handle)

    创建窗口句柄错误.这个错误非常头疼,难以排查,我从网络上搜集了一些排查方案. 可能的原因: 窗口句柄泄露,句柄数超过1W. 用户对象超过1W,错误提示"当前程序已使用了 Window 管理器 ...