Question
____________________________________________________________ public class LabArray { /****************************************************** * Follow the instructions in main * the expected output is listed at the end of this file *******************************************************/
____________________________________________________________
public class LabArray
{
/******************************************************
* Follow the instructions in main
* the expected output is listed at the end of this file
*******************************************************/
public static void main(String[] args)
{
// create int array named intArray of size 3
// use the method printArray to print the array; pass as name
"intArray"
// assign the value 2 to the first element
// use the field length to assign the value 4 to the last element
// print all elements of intArray
// in a separate line print the lenght of intArray
// create an integer variable named number and assign it the value 3
// assign number plus 4 (as an expression) to the second element of
intArray
// assign the value of the first element to the third element of
intArray
// print all elements of intArray
}
private static void printArray(int[] integerArray, String name)
{
System.out.printf("%s: ", name);
for (int i = 0; i < integerArray.length; i++)
{
System.out.printf("%d ", integerArray[i]);
}
System.out.println();
}
/*****************************
* Expected Output:
*
* intArray: 0 0 0
* intArray: 2 0 4
* length of intArray: 3
* intArray: 2 7 2
******************************/
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started