Language:EN
Pages: 2
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
array string objects called args

Array string objects called args

Using Arrays and Collections

When we execute this code, we get the following output:

Length of arr2: 5

changeArray
arr
arr2

changeArray

0
0
0
0
0

main main
Before allocation of

After allocation of

new array

new array

The length property of a Java array will tell us how many command-line arguments were used. The first argument of the array will contain the first command-line parameter. The second will contain the second command-line parameter, and so forth.

The following CommandLineDemo application illustrates the use of the args array:

System.out.println("\tArgument Number " + i +

": " + args[i]);

java CommandLineDemo /D 1024 /f test.dat

The output of the program would appear as follows:

Argument Number 3: test.dat

[ 139 ]

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : David Hughes

PageId: DOCB9430B4