当前位置:网站首页>JZ5 替换空格
JZ5 替换空格
2022-07-20 21:38:00 【syc596】
// //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();
}
}
边栏推荐
- Let me introduce you to the partition automatic management of data warehouse
- Dama Chapter 11 (data warehouse and business intelligence)
- Industrial application of cartoon 3D virtual image production
- Is it safe for GF futures to open an account online? Are there any account opening guidelines?
- conda虚拟环境默认路径如何修改
- Using go TCP to realize simple online group chat function
- Dama summary (summary of data management)
- i2c client驅動
- What information can the real-time market of London Silver bring to people
- Is there any risk in opening a mobile stock account? Is it safe?
猜你喜欢
Opengauss kernel analysis: query rewriting
[stc15 controls ws2812 RGB color lamp cascade]
Dama Chapter 3 (Data Governance)
To test / development programmers: programmers who love life, don't work overtime, and are forced
Lora technology helps cold chain development
TransUNet: Transformers Make Strong Encoders for Medical Image Segmentation
Lora base station coverage
Esp8266 nodemcu -- use u8g2 library to light OLED
Dama Chapter 8 (data integration and interoperability)
[digital image processing / bilateral filtering experiment] high score course experiment report sharing
随机推荐
i2c adapter驱动
Starfish OS: create a new paradigm of the meta universe with reality as the link
2022第五届中国(济南)国际青少年眼健康产业展览会9月举办
Tian Wei, architect of Alibaba cloud native application platform: planning, governance and evolution of application architecture
i2c client驅動之IIO設備驅動
In depth analysis: how chain 2+1 mode plays with investment attraction and drainage
How can traditional retail enterprises promote consumption cycle and share purchase mode to enable the development of physical enterprises?
Dama Chapter 11 (data warehouse and business intelligence)
If no linetype is selected, the reason why cacuilinetypecombobox crashes
[example] input text in the input box to output the typewriter effect
Wechat applet - "data binding and event binding"
Message: no NPM package can be built. Please confirm that the NPM to be built is in the 'miniprogramroot' directory, or configure project config. Packnpmmaof JSON
Ipaylinks, a cross-border payment integration service, won the 3A Asia Award of the asset!
Let's go - Recruitment book for reading activities in 2022 (issue 1)
PHP cross domain solution
Origin 2022 download nanny level installation tutorial
2.4 circular statements
Several stumbling blocks of it entrepreneurs
Realize joint testing through TPT fusion platform
Solve the problem of error reporting in NPM installation NRM syntaxerror: unexpected token import