Consider the following main method public static voidmain(String[] args) { } Com
ID: 3611102 • Letter: C
Question
Consider the following main methodpublic static voidmain(String[] args)
{
}
Complete the body of this method by writing inside the curly bracesthe code specified in the following requirements:
-Define an array of integers(onedimension) and initialise it with the following values:-8,3,0,9,7. What is the length of the array that u just initializedand the value that appears at index 3. If u get this far, can uwrite a code that can print on the terminal window your initializedarray?
Now that u know about arrays, can u write the code that prints thefirst element of your array?
Mark only if the final code is given. Otherwise the mark is 0.
Explanation / Answer
import java.io.*; import java.util.*; import java.lang.*; public class ArrayPrint { public static void main(String [] arg) { int[] integers ={-8, 3, 0, 9, 7}; System.out.println("length of the ArrayIntegers[] is: " + integers.length); /*printing the element of the array at index 3*/ System.out.println("Element at index 3 is: " +integers[3]); /* printing the array */ System.out.println(); System.out.println("printing the array"); for(int i=0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.