【问题标题】:How to create an index out of bounds exception?如何创建索引越界异常?
【发布时间】:2016-09-30 17:23:00
【问题描述】:

我有一个不寻常的问题。 您将如何在功能完善、简单的 ArrayList 代码中故意创建 IndexOutOfBoundsException?

谢谢!

【问题讨论】:

  • 什么编程语言?
  • 如果它抛出异常,它仍然可以正常运行吗?
  • 哦,对了,对不起。我现在正在谈论Java。关键是要有一个功能齐全的代码,但它仍然有 IndexOutOfBoundsException。

标签: string arraylist integer int indexoutofboundsexception


【解决方案1】:

你可以这样做:

List list = new ArrayList<>();
list.get(0);

这就是你所追求的吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-19
    • 2013-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-31
    • 2015-12-08
    • 2011-10-08
    相关资源
    最近更新 更多