简单数组中的错误...如何修复 [英] Error in simple array... How to fix

查看:48
本文介绍了简单数组中的错误...如何修复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这给了我一个错误:

当提供数组初始值设定项时无法定义维度表达式.

Cannot define dimension expressions when an array initializer is provided.

如何解决?

static String names[] = new String[8]{
 "Global Mining Technologies",
 "Advanced Mine Group",
 "Hi-Tech Mining Industrial",
 "Victory Mining Co.",
 "Miners of Land Inc.",
 "Space-Age Mining Industries",
 "EasyMine Co.",
 "C.R.A.F.T Mining"};

推荐答案

正如错误所提到的那样.要么指定维度而不初始化内联,要么不指定维度并允许初始化元素.

It's exactly as the error mentions. Either you specify dimensions and don't initialize inline, or you don't specify dimension and are allowed to initialize elements.

改用这个习语:

static String names[] = {
 "Global Mining Technologies",
 "Advanced Mine Group",
 "Hi-Tech Mining Industrial",
 "Victory Mining Co.",
 "Miners of Land Inc.",
 "Space-Age Mining Industries",
 "EasyMine Co.",
 "C.R.A.F.T Mining"};

这篇关于简单数组中的错误...如何修复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆