作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
考虑:
public proj 3 {
static string [][]Item;
public static void main(String [] args){
Item[][] = {
{"BH," , "Backhoe," , "200.00"},
{"ER," , "Electric Rake," , "10.00"},
{"EL," , "Electric Lawnmower," , "15.00"},
{"TR," , "Trencher" , "35.00"},
{"MU," , "Mulcher," , "20.00"},
{"TS," , "Tree Sprayer," , "22.00"},
{"CP," , "Cider Press," , "30.00"},
{"PR," , "Pruner," , "12.00"},
{"GE," , "Gas Edger," , "20.00"},
{"RO," , "Roller," , "8.00"},
我怎样才能做到这一点,以便我可以从不同的方法调用数组?
最佳答案
这意味着你必须像这样初始化它:
public class Proj3{
public static String [][] Item = {
{"BH," , "Backhoe," , "200.00"},
{"ER," , "Electric Rake," , "10.00"},
{"EL," , "Electric Lawnmower," , "15.00"},
{"TR," , "Trencher" , "35.00"},
{"MU," , "Mulcher," , "20.00"},
{"TS," , "Tree Sprayer," , "22.00"},
{"CP," , "Cider Press," , "30.00"},
{"PR," , "Pruner," , "12.00"},
{"GE," , "Gas Edger," , "20.00"},
{"RO," , "Roller," , "8.00"}
};
public static void main(String [] args){
...
}
如果要使用数组初始值设定项,则不能拆分声明和赋值。
关于java - 数组常量只能用于初始化错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6348479/
有一条(相对)众所周知的 Perl 公理:“只有 Perl 可以解析 Perl”。我想知道 Perl 6 是否仍然如此? 扩大讨论...考虑到 PyPy 最近的更新,我想到了这个问题。 Perl 独特
这是设置。在上一个问题中,我发现我可以通过子组件中的状态传递对象属性,然后使用 componentDidUpdate 获取该对象属性。在这种情况下,状态和属性都称为到达。 这是基本代码... expo
我运行的是 10.5.2 社区版。我已经标记了 源/主要/资源 作为源目录。我可以右键单击并“编译”某些文件,据我所知,这意味着 IDE 将文件复制到与发送类文件的“com.mydomain.pack
我是一名优秀的程序员,十分优秀!