//字符串中找最大数字
class Untitled {
public static void main(String[] args) {
String str = "abc123de4567ff";
char[] cs = str.toCharArray();
int count = 0;
int max = 0;
int end = 0;
for(int i = 0; i < cs.length; i++){
if(Character.isDigit(cs[i])){
count++;
}
else{
if(count > max){
max = count;
end = i;
}
count = 0;
}
}
String s1 = str.substring(end-max, end);
System.out.println(s1);
}
}
class Untitled {
public static void main(String[] args) {
String str = "abc123de4567ff";
char[] cs = str.toCharArray();
int count = 0;
int max = 0;
int end = 0;
for(int i = 0; i < cs.length; i++){
if(Character.isDigit(cs[i])){
count++;
}
else{
if(count > max){
max = count;
end = i;
}
count = 0;
}
}
String s1 = str.substring(end-max, end);
System.out.println(s1);
}
}
全部评论
相关推荐

点赞 评论 收藏
分享
07-08 20:34
宁夏理工学院 软件测试 点赞 评论 收藏
分享
08-10 12:43
临沂大学 Java 等闲_:1,换一个模版,这个模版没有人会看的 2,项目太烂大街了,也太简单了,找AI优化一下描述,项目可以烂大街,但是简历不能烂大街,或者找项目换一下 3,如果没什么奖的话,把学校放到下面,添加一个个人描述,简单些,让简历丰富一些 4,改完之后海投试试,但是我真的很建议别走java了,可以试试前端
点赞 评论 收藏
分享