小编jav*_*ser的帖子

如何在特定索引处的字符串中添加换行符?

我有一个字符串:

String testString= "For the time being, programming is a consumer job, assembly line coding is the norm, and what little exciting stuff is being performed is not going to make it compared to the mass-marketed cräp sold by those who think they can surf on the previous half-century's worth of inventions forever"
Run Code Online (Sandbox Code Playgroud)

像这样:暂时,programmi \n ........ \n ....... \n

在此字符串中每个长度为20个字符之后,我想在Android中的TextView中放置换行符\n以显示.

java string android

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

如何在java中替换字符串

我有以下代码

String rplaceString="John = Max and Jing => Sira then nothing";
String replaced=rplaceString.replace("=", "==").replace("=>", "=>");
System.out.println("REPLACE STRINF==>>>>>>>>"+replaced);
Run Code Online (Sandbox Code Playgroud)

预期的输出字符串像这样:

String expectedString="John == Max and Jing => Sira then nothing";
Run Code Online (Sandbox Code Playgroud)

如果我做上面的方法,输出看起来像:

REPLACE STRINF == >>>>>>>> John == Max和Jing ==> Sira然后什么也没有

那么,如何在预期的字符串中替换上面的字符串.

编辑:更改字符串像这样: John = Max和Jing => Sira然后什么也没有

要么

John = Max和Jing => Sira然后什么也没有

要么

John = Max和Jing => Sira然后什么也没有

java string replace

0
推荐指数
1
解决办法
121
查看次数

标签 统计

java ×2

string ×2

android ×1

replace ×1