public class Test2 {
public static void main(String[] args) {
String ss="hfgjh37389457jfghdkj71211156897dfjkghdjkgh847IROWUE5789748978476894869477";
StringBuilder sb1=new StringBuilder();
String sb2="";
char[] cc=ss.toCharArray();
for(int i=0;i<cc.length;i++){
if(cc[i]>='0'&&cc[i]<='9'){
sb1.append(cc[i]);
}else{
if(sb1.length()!=0){
sb2=sb1.length()>sb2.length()?sb1.toString():sb2;
sb1.setLength(0);
}
continue;
}
}
if(sb1.length()>sb2.length()){
System.out.println(sb1.toString());
}else{
System.out.println(sb2);
}
}
找出最长数字串
最新推荐文章于 2022-05-18 13:46:08 发布