Java Exception in thread "main" 。

求助:我照着教材上打的代码,为啥运行不了?下面写着:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 12

at PanelGridLayout.<init>(PanelGridLayout.java:10)

at ShowLayout.<init>(ShowLayout.java:8)

at Example9_4.main(Example9_4.java:3)

还有这种左边为啥会有个黄色的感叹号?

public class PanelGridLayout extends JPanel{

这是啥意思?要咋整?感叹号内写着:

Adds a default serial version ID to the selected type.

Use this option to add a user-defined ID in combination with custom

serialization code if the type did undergo structural changes since its

first release.

图片说明图片说明图片说明图片说明

图片说明

对了,还有一个问题,ShowLayout.Java里最后一句:volidate()是什么意思呀?有什么用?

回答

数组索引越界,PanelGridLayout的第9行,for循环条件,应该是j<12,不是i<12

以上是 Java Exception in thread "main" 。 的全部内容, 来源链接: utcz.com/a/43131.html

回到顶部