Question: Write a program to create an array with 5 integer values: 10, 20, 30, 40, 50. And then print the array data to monitor. This

Write a program to create an array with 5 integer values: 10, 20, 30, 40, 50. And then print the array data to monitor. This is what i have, but i get errors in the code.

package lab1; import java.util.Scanner; public class Lab1 {

public static void main(String[] args) { private static Scanner scanner = new Scanner(System.in);

public static void main(String[] args) { int[] array = {10,20,30,40,50}; System.out.println("Number at index 0: "+array[0]); System.out.println("Number at index 1: "+array[1]); System.out.println("Number at index 2: "+array[2]); System.out.println("Number at index 3: "+array[3]); System.out.println("Number at index 4: "+array[4]); } } }

I am trying to do this on netbeans but i am stuck and cant figure this out, can someone help me please

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!