This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
1. public class CommandArgsThree { 2. public static void main(String [] args) { 3. String [][] argCopy = new String[2][2]; 4. int x; 5. argCopy[0] = args; 6. x = argCopy[0].length; 7. for (int y = 0; y < x; y++) { 8. System.out.print(" " + argCopy[0][y]); 9. } 10. } 11. } the answer is : D. In line 5, the reference variable argCopy[0], which was referring to an array with two elements, is reassigned to an array (args) with three elements how did assign array of 2 elements to array of 3
vidya sagar
Ranch Hand
Joined: Mar 02, 2005
Posts: 580
posted
0
argCopy[0] = args; how did assign array of 2 elements to array of 3
args is one dimensional array argcopy is two dimensional array
argcopy[0] can have address of single dimensional array or null argcopy[0][0] can have values
argCopy[0] = args; In our case we are having address of args to argcopy [i.e address of one dimensional array to argcopy[0]]
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
posted
0
Referring to the first post: What is the full question?