小编Man*_*nju的帖子

java.lang.IndexOutOfBoundsException:索引:0,大小:0异常

我收到错误java.lang.IndexOutOfBoundsException:Index:0,Size:0.

public Collection<AdDistribution> getAdDistribution(byte srch, byte cont) throws IndexOutOfBoundsException {

    List<AdDistribution> mediums = new ArrayList<>();
    List<AdDistribution> adDistribution = new ArrayList<>();
            adDistribution.add(AdDistribution.SEARCH);
            adDistribution.add(AdDistribution.CONTENT);
            if (adDistribution.isEmpty()) {
                return null;
              }

    if (srch == 0 && cont == 0) {
        mediums = new ArrayList<>();
        mediums.set(0, adDistribution.get(0));
    }
    if (srch == 1 || cont == 1) {
        mediums = new ArrayList<>();
        if (srch == 1) {
            mediums.set(0, adDistribution.get(0));
        } else if (cont == 1) {
            mediums.set(0, adDistribution.get(1));
        }
    }
    if (srch == 1 && …
Run Code Online (Sandbox Code Playgroud)

java indexoutofboundsexception

4
推荐指数
2
解决办法
6万
查看次数

标签 统计

indexoutofboundsexception ×1

java ×1