【发布时间】:2014-10-18 11:47:54
【问题描述】:
我有一个方法 A,我在其中创建了一个数组。现在我想在另一个方法 B 中使用数组,想知道是否有可能在方法 B 中调用方法 A 并使用数组而不是在我创建的每个方法中创建数组。
public static void myArray() {
String[][] resultCard = new String[][]{
{ " ", "A", "B", "C"},
{ "Maths", "78", "98","55"},
{ "Physics", "55", "65", "88"},
{ "Java", "73", "66", "69"},
};
}
public static void A() {
//Not sure how I can include the array (myArray) here
}
public static void B() {
//Not sure how I can include the array (myArray) here
}
【问题讨论】:
-
显示部分代码...这将详细解释您所说的内容...不仅文字,甚至代码都可以解释!
-
是的,使用了实例变量(在方法之外声明),或者使用方法返回。
-
你的标题有点误导(而且毫无意义)......
-
不确定你的意思,但我会根据我认为我理解的内容给你一个答案。