aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Array" Watch "Array" New topic
Author

Array

Netty poestel
Ranch Hand

Joined: Sep 20, 2004
Posts: 131
Here's something I'm stumbling with



and the command-line invocation,
java CommandArgsThree 1 2 3
Q-->what is the result?

I'm not being able to interpret this code.
from intial feedbacks this is how I'm seeing the picture


each element in "argcopy" contains an array of 2 elements as shown
above 'argcopy' [ could not draw the linking lines properly....too painful ]
considering 'x = argCopy[0].length;' should be 3 , what is happening with

System.out.print(" " + argCopy[0][y]); // in terms of the boxes I have
drawn. If at all I have drawn them in the proper way.

TIA

( tags added and an attempt to format the code)
[ November 10, 2004: Message edited by: Barry Gaunt ]
Atul Chandran
Greenhorn

Joined: Oct 24, 2004
Posts: 22
5. argCopy[0] = args;

after this line argCopy[0] will be refering to the array of length 3 which is reffered to by arg.

before line 5
argcopy[0]-------->[null] [null] /*an array of length 2 whose elements are initialized to null.*/


after line 5.
argcopy[0]-------->["1"] ["2"] ["3"]//an array of length 3 .

[ November 10, 2004: Message edited by: Atul Chandran ]

[ November 10, 2004: Message edited by: Atul Chandran ]
[ November 10, 2004: Message edited by: Atul Chandran ]
Netty poestel
Ranch Hand

Joined: Sep 20, 2004
Posts: 131
Originally posted by Atul Chandran:
5. argCopy[0] = args;

after this line argCopy[0] will be refering to a new array of length 3.

before line 5
argcopy[0]-------->[0] [0] //an array of length 2 initialized to 0.


after line 5.
argcopy[0]-------->[1] [2] [3]//an array of length 3.

[ November 10, 2004: Message edited by: Atul Chandran ]

[ November 10, 2004: Message edited by: Atul Chandran ]



Howdy..

(i)
"before line 5 argcopy[0]-------->[0] [0] an array of length 2 initialized to 0."

since it's a String array, shouldn't that be initialized as a null ?


(ii)
"after this line argCopy[0] will be refering to a new array of length 3."

would this mean that argcopy is now referring 'also' to a 3rd new array. ? so are the original 2 are stll connected at this point ?

Thx.
Atul Chandran
Greenhorn

Joined: Oct 24, 2004
Posts: 22
Sorry my mistake ...you are right..I have editided my post...Didn't look at the code closely.
 
 
subject: Array