我收到錯誤java.lang.IndexOutOfBoundsException:指數:0,大小:0java.lang.IndexOutOfBoundsException:指數:0,大小: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 && cont == 1) {
mediums = new ArrayList<>();
mediums.set(0, adDistribution.get(0));
mediums.set(1, adDistribution.get(1));
}
return mediums;
}
u能分享修改後的代碼 – Manju
在我的回答:「你需要使用[修改代碼]而不是[你的代碼]「。對不起,這就是你從我這裏得到的一切:你需要自己付出一些努力。 –