public static void main(String[] args) { List<Object> fileCountLs = new ArrayList<>(); Object o = new Object(); fileCountLs.add(o); AtomicInteger sortNo = Objects.nonNull(fileCountLs) ? new AtomicInteger(fileCountLs.size() + 1) : new AtomicInteger(1); System.out.println(sortNo.intValue()); //序号自增 sortNo.getAndIncrement(); //System.out.println( sortNo.getAndIncrement()); System.out.println( sortNo); }