当前位置:网站首页>Jz5 replace spaces
Jz5 replace spaces
2022-07-21 16:36:00 【syc596】
Replace blank space _ Niuke Tiba _ Cattle from (nowcoder.com)
// //string->char[]->string
// import java.util.*;
// public class Solution {
// public String replaceSpace (String s) {
// char[] array=new char[s.length()*3];
// int index=0;
// for(int i=0;i<s.length();i++){
// if(s.charAt(i)==' '){
// array[index++]='%';
// array[index++]='2';
// array[index++]='0';
// }else{
// array[index++]=s.charAt(i);
// }
// }
// String ret=new String(array,0,index);
// return ret;
// }
// }
//stringbuffer
import java.util.*;
public class Solution {
public String replaceSpace (String s) {
StringBuffer sb=new StringBuffer();
for(int i=0;i<s.length();i++){
if(s.charAt(i)==' '){
sb.append("%20");
}else{
sb.append(s.charAt(i));
}
}
return sb.toString();
}
}
边栏推荐
- 2.4 circular statements
- In the e-commerce industry with fierce competition, why can the chain 2+1 mode survive for so long?
- I2C client Drive
- To test / development programmers: programmers who love life, don't work overtime, and are forced
- Why is sha256 irreversible and how secure is sha256
- Database constraint & MySQL advanced query
- MoviePy error: FFMPEG encountered the following error while writing file
- Realize joint testing through TPT fusion platform
- Dama Chapter 8 (data integration and interoperability)
- Three structures of C language
猜你喜欢
專注跨境支付一體化服務 iPayLinks榮獲《財資》(The Asset)3A亞洲獎!
Calculate the centrifugal angle according to the center angle of the circle
How to modify the default path of CONDA virtual environment
Lora base station coverage
[JS] event communication
RKE vs. RKE2:对比两种 Kubernetes 发行版
The difference between soft link and hard link and how the file system takes files
Dama Chapter 8 (data integration and interoperability)
Wang fried power to create wealth fast! Xiangling giant panda 2.0 power products officially launched
DTOs' 3D engine will replace the game engine monster and realize localization
随机推荐
Tian Wei, architect of Alibaba cloud native application platform: planning, governance and evolution of application architecture
Communication mode of PLC
What information can the real-time market of London Silver bring to people
2.3 branch statements
Dam Chapter 13 (data quality management)
MoviePy error: FFMPEG encountered the following error while writing file
Dama Chapter 8 (data integration and interoperability)
Three structures of C language
. Net core load assembly assemblyloadcontext
Le moteur 3D de dtos titos remplacera le moteur de jeu Giant Beast et réalisera la substitution de localisation
L'ipaylinks, un service d'intégration des paiements transfrontaliers, a remporté le prix 3A Asia de l'actif!
Is there any risk in opening a mobile stock account? Is it safe?
Zhaocai meow | jade meow, brother Tai pours ten thousand Liang, a pear flower, a summer rain
Wechat applet - "data binding and event binding"
Five reasons why developers use Klocwork for software security
JS optional chain
How to modify the default path of CONDA virtual environment
How cloud primitives support enterprise IT governance | Alibaba cloud user group
Several stumbling blocks of it entrepreneurs
Dama Chapter 4 (data architecture)