猿问

有关java程序执行的问题!


答案是输出1然后报错,为啥?...

webic
浏览 1458回答 3
3回答

Yexiaomo

你看报错的信息  :Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1一看就是数组下标越界了, array index out of bourds exception --------------------其实你就把这个看成普通的函数如:public static void main(String[] args) {     System.out.println(args[0]);     System.out.println(args[1]); }你输入参数,不就是相当于传参,你只传了一个,你却打印两个,所以一定会抛出下标越界异常

道临

因为你就传递了一个参数“1”,而这是要打印两个参数,所以第二条打印语句执行时会报空指针异常啊

慕的地8582982

BAHRPVFVKEMRSWTPLJTIZWCSOEHENEHDGIRTVYBZBKUFLHRNYPFJLHXDENDUFIXAPTZIYJMWSJFBRENKTJGWAPSJZVSBLBKHQTRKMJUXTXAPMVHQAFOLTDMIZMBDNDZWGOSIBQTCHKAEGJMNPXUXOEUJSVDTCLVRPTBMHUQAJFIACLWTNWFVZCZVEBPOLHZORVZOKSAIFOEBYUJMBAPGPFPSPXPFNWMJTPYVRISPGQMCFPENQZZOEBKVTVROQJMCSARUENKHCLILORURNCFXUCFCFWZIYBORUQNQMGDAWRBMPEBEUXHRMPLPFPFIKHDGIGPYVLOIYVJZBSPLUSNQCQNDMCTDMIYPVKVZIEADSVRDMPFCFBENCMQYDNDGPLUJFUXHRHEZCMWMTPZVSWYOKHDYAQMITKMVMCJROXUEHKNWMBHNNXHEMBMEDYWSPGKGVYIGILUFCZBXOXJPKDUOLBHZWVYIEAQUDFPSMNXHXHQAWMPJMVYBKBKGDZWRIYBDNXTWGCLOCFVMCRHKDMISPMCXGEAYAQTDMNYUXUEGDTWTILGQYQLPGWFOLNDBSBXMDZJMHYBRZWLBFOKGCMRAEILHMHDZXCRHLNLNIRCSFAXGPAQSVFIGAKGQGXHQGPGDGWMPFHDOWPFXZDHYAKNCCJZCLHXTPLVIKNKGIYOQUKDRNRBXZQSVSQSHXTJZIKOESPEOEASBDUDVDGDAOSPRIYHCMDNKMCSWRZCZUEUQTIYCUWTIYACFHEUGBLIYHRORARJFCRBYVXSQNRNWSIFPMPRSYOLISOYOKVEUDGCGDGBRUKPLHLCFUETXNQYWSCFPNCZWYTWTJZWAPYBWEJARBJHOSZADRBPMTUAYLWCTMALVJQTU
随时随地看视频慕课网APP

相关分类

Java
我要回答