当前位置:网站首页>Separate the letters and numbers in the string so that the letters come first and the array comes last
Separate the letters and numbers in the string so that the letters come first and the array comes last
2022-07-01 22:08:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
Big search car school recruitment programming problem :
Separate the letters and numbers in the string and make the letters in the front and the array in the back
public class The school recruit {
static String stringCharFrontNumEnd(String string){
if(string==null ||string.length()==0)
return null;
String charString="";
String numString="";
for(int i=0;i<string.length();i++){
if(string.charAt(i)>='0' && string.charAt(i)<='9')
System.out.println(string.charAt(i));
numString=numString + string.charAt(i);
if(string.charAt(i)>='a' && string.charAt(i)<='z' || string.charAt(i)>='A' && string.charAt(i)<='Z')
charString= charString + string.charAt(i);
}
return charString+numString;
}
public static void main(String[] args) {
String string="h3a2p0p1y";
System.out.println(string + " --> " + stringCharFrontNumEnd(string));
}
}
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/147191.html Link to the original text :https://javaforall.cn
边栏推荐
猜你喜欢
随机推荐
【STM32】STM32CubeMX教程二–基本使用(新建工程点亮LED灯)
使用闭包实现点击按钮切换 toggle
都能看懂的LIS(最长上升子序列)问题[通俗易懂]
PHP 读取ini或env类型配置
打出三位数的所有水仙花数「建议收藏」
微信小程序,连续播放多段视频。合成一个视频的样子,自定义视频进度条
Difference and use between require and import
PMP证书真的有用吗?
联想电脑怎么连接蓝牙耳机?
辅音和声母的区别?(声母与辅音的区别)
杰理之蓝牙耳机品控和生产技巧【篇】
Case of camera opening by tour
Fundamentals - IO intensive computing and CPU intensive computing
Basic operation of binary tree
Aidl basic use
List announced | outstanding intellectual property service team in China in 2021
String类型转换BigDecimal、Date类型
Do you want to make up for the suspended examination in the first half of the year? Including ten examinations for supervision engineers, architects, etc
Microsoft, Columbia University | Godel: large scale pre training of goal oriented dialogue
leetcode刷题:栈与队列01(用栈实现队列)