Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class StudyClass {
  4.     public static void main (String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.         System.out.println("Please input the length of the array.");
  7.         int num = input.nextInt();
  8.         Constructor testInput = new Constructor(num);
  9.         input.close();
  10.     }
  11. }
  12. /**
  13.  * Take scanner input and set that for the limit of the array length.  
  14.  * Then run a loop to print out the numbers that have been put into the array.
  15.  */
  16. public class Constructor {
  17.     public Constructor (int testInput){
  18.         //Int. the array
  19.         final int LIMIT = testInput;
  20.         int[] Test = new int[LIMIT];
  21.         for(int loop = 0; loop<LIMIT; loop++){
  22.             Test[loop] = loop;
  23.         }
  24.           for (int i=0; i<LIMIT; i++)
  25.               System.out.print (Test[i] + "  ");
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement