これは私の 2 次元配列です。
String[][] theMaze = new String[row][column];
この方法でそれを使用する方法は?
public void ruteToX(String[][] theMaze){
// call theMaze and process in this method
}
これは私の 2 次元配列です。
String[][] theMaze = new String[row][column];
この方法でそれを使用する方法は?
public void ruteToX(String[][] theMaze){
// call theMaze and process in this method
}
あなたの質問を正しい意味で理解したと仮定します。
メソッドに配列を渡す例を示しますruteToX(...)
。
public class Example
{
String[][] theMaze = new String[5][5];
public void ruteToX(String[][] theMaze)
{
//call theMaze and process in this method
}
public static void main(....)
{
Example ob=new Example();
ob.ruteToX(ob.theMaze);
//passed the value of reference or the pointer to the function ruteToX(...)
}
}
それはどのように渡されますか?
配列を渡すとpointer or reference
、メモリ内の値が渡されます。つまり、メソッドでパラメーター配列に変更を加えると、実際の配列も同じ変更に直面します (同じ参照であるため)。