- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在其中一个视频教程中看到了下面的代码。它执行得很好,但是当我尝试在我的系统中执行时,它编译得很好,但我收到运行时错误,
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
class Test13
{
public static void main(String[] args)
{
int i = Integer.parseInt(args[0]);
System.out.println(i);
}
}
有人可以指导我这段代码有什么问题以及如何纠正吗?
提前致谢!
最佳答案
看起来您在运行代码时没有传递任何参数。
来自Java doc for ArrayIndexOutOfBoundsException : '抛出该异常表示已使用非法索引访问了数组。索引要么为负数,要么大于或等于数组的大小。'
因此,您尝试从索引为 0 的 args 数组中提取一个值,但该数组小于此大小(在本例中为空)。
为了防止抛出异常,您可以在语句周围应用大小检查。
if(args.length>0) {
int i = Integer.parseInt(args[0]);
System.out.println(i);
}
关于java - 如何克服 Integer.parseInt(args[0]) 的 ArrayIndexOutOfBoundException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34720857/
据我所知,Marketo 将 REST API 请求的数量限制为每天 10,000 次。有没有办法克服这个限制?我可以支付并获得更多吗? 我发现 REST API 请求和 SOAP API 请求是分开
有谁知道有什么方法可以克服 NotSupportedException?我有一个针对用户的方法: public virtual bool IsAbove(User otherUser) {
我们最近从关系型 (MySQL) 转向 NoSQL (couchbase)。基本上它是社交手机游戏的后端。我们在扩展后端以处理越来越多的用户时面临着很多问题。当使用 MySQL 时,由于多个表之间存在
我当前用来收集文本的函数 InputBox 显然不能接受超过 255 个字符,并且我需要能够收集更多字符?我可以使用参数或不同的函数来增加此限制吗? 最佳答案 说句迂腐的话,输入框允许您输入最多 25
我是近似字符串匹配领域的新手。 我正在探索 Bitap algorithm 的用途,但到目前为止,它有限的模式长度让我很困扰。我正在使用 Flash,处理 32 位无符号整数和一个 IEEE-754
克服 PHP 中的大海捞针困惑的最实用方法是什么? 这里 $needle 是第一个参数 bool in_array ( mixed $needle , array $haystack [, bool
我有一个无法更改的客户端类。 List list1= Arrays.asList(1,2,3); System.out.println("Total sum is:"+sum(list1)); pri
我们都知道,在 Java 中,如果在 Abstract 类中声明一个 static 方法,该方法将属于 Abstract 类,而不是它的 child 。 (没有抽象静态) 我有一个简单的数据库系统,它
我有 4 个表和这个查询 SELECT tag.id, title FROM tag LEFT JOIN tag_map ON ( tag.id = tag_map.tag_id ) LEFT JOI
我有 4 个表和这个查询 SELECT tag.id, title FROM tag LEFT JOIN tag_map ON ( tag.id = tag_map.tag_id ) LEFT JOI
在 Swift 中,一切都以结构而不是类的形式实现。正在传入值,但内存地址不存储它们。这是一个例子: import UIKit var array = Array() array = [6,2,9,1
在我编写的 C++ 程序中: #include #include using namespace std; int main() { vector a; a.resize(1); f
我正在尝试使用 php_ldap(使用 ADLdap)从 Ubuntu(hardy 8.04LTS)主机绑定(bind)到 AD。在端口 389 上绑定(bind)到 ldap://myserver
这个问题在这里已经有了答案: Low picture/image quality when capture from camera (3 个答案) 关闭 5 年前。 我想从相机拍照并上传到服务器,但
我想将 unsigned char[8] 分配给 uint64(c 语言),使用 RPC 传递此值,并将 uint64 转换回具有相同字节顺序的 unsigned char[8](cpp 语言)。问题
Python 似乎对实例方法有一些限制。 无法复制实例方法。 不能 pickle 实例方法。 这对我来说是有问题的,因为我的工作是非常面向对象的 project我在其中引用了实例方法,并且同时使用了深
我理解这个问题,根据答案 here ,但是,我真的可以使用帮助或更详细的代码解释来说明它是如何克服的。 我的情况是这样的:我曾经将模型和 Controller 分开,在我的模型包中我有一个包含所有模型
假设我从这样的 Akka Persistence 系统开始: case class MyMessage(x: Int) class MyProcessor extends Processor {
我正在寻找在构建重量级 Windows 界面时处理用户对象句柄限制的高级策略。请说明您如何使用 SWT 或直接 Windows GUI API 克服或绕过此问题。我唯一不感兴趣的是优化小部件使用的策略
我有一个我知道过去的日期列表,但格式为 28/MAY/13 .用它们制作日期类的最接近的方法是基本的 dates as.Date("2013-12-31")] as.Date("2013-12-3
我是一名优秀的程序员,十分优秀!