题解 | #在字符串中找出连续最长的数字串#
https://www.nowcoder.com/practice/2c81f88ecd5a4cc395b5308a99afbbec
import java.util.*; public class Main{ public static void main(String[] args){ Scanner scanner = new Scanner(System.in); while(scanner.hasNext()){ String str = scanner.nextLine(); String[] nums = str.split("\\D+"); int max = 0; List<String> list = new ArrayList<>(); for(String num:nums){ if(num.length() > max){ max = num.length(); list.clear(); list.add(num); }else if(num.length() == max){ list.add(num); } } System.out.printf("%s,%d%n",String.join("",list),max); } } }