当我尝试编译这个简单的程序时出现上述错误:
/* @author
* This program expects two command-line arguments
* -- a person's first name and last name.
* For example:
* C:\Mywork> java Greetin Annabel Lee
*/
public class Greetin
{
public static void main(String[] args)
{
String firstName = args[0];
String lastName = args[1];
System.out.println("Hello, " + firstName + " " + lastName);
System.out.println("Congratulations on your second program!");
}
}
通过查看其他问题,我了解错误与数字有关args == 0
并且0
大于数字,但我不知道如何解决这种情况下的问题。有什么方法可以将错误也识别为由void
?