Question
Can you explain to me what is going on with this code? Thanks. import java.util.*; public class ArrayDemoObj{ public static void main (String arg [
Can you explain to me what is going on with this code? Thanks.
import java.util.*;
public class ArrayDemoObj{ public static void main (String arg [ ] )throws Exception{ PositiveNumber myArray[ ]= new PositiveNumber[5]; int num = 88; Scanner sc = new Scanner(System.in); for (int i=0; i< myArray.length; i++){ System.out.println(myArray[i]); } System.out.println("**************"); System.out.println("The array length is: "+ myArray.length); sc = new Scanner(System.in); sc.nextLine( ); PositiveNumber pn = new PositiveNumber(num); Arrays.fill(myArray, pn); for (int i=0; i< myArray.length; i++){ System.out.println(myArray[i]); } pn.setNum(45); for (int i=0; i< myArray.length; i++){ System.out.println(myArray[i]); } } }
Can you help me make one? Not really sure how to do it. I just want to know how it works.
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