using java Arrays Create a Class to store 100 integers in an

using java

(Arrays) Create a Class to store 100 integers in an Array. Call your class “SimpleArray”, and store it in a file called “SimpleArray.java”. All code should go in the main() method. First declare an array of 100 integers. Use a for loop to store the numbers between 500 and 599 in the array. Then build a second loop to print out the data in this array.

Solution

SimpleArray.java


public class SimpleArray {

   public static void main(String[] args) {
       int array[] = new int[100];
       for(int i=0, j=500; i<array.length; i++,j++){
           array[i] = j;
       }
       System.out.println(\"Arrays elemnts are: \");
       for(int i=0; i<array.length; i++){
           System.out.print(array[i]+\" \");
       }

   }

}

Output:

Arrays elemnts are:
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599

using java (Arrays) Create a Class to store 100 integers in an Array. Call your class “SimpleArray”, and store it in a file called “SimpleArray.java”. All code

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site