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
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