m0_46634941 2020-09-10 16:24 采纳率: 100%
浏览 134
已采纳

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()是什么意思呀?有什么用?

  • 写回答

2条回答 默认 最新

  • jingluan666 2020-09-10 16:31
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办