Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class StudyClass {
- public static void main (String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.println("Please input the length of the array.");
- int num = input.nextInt();
- Constructor testInput = new Constructor(num);
- input.close();
- }
- }
- /**
- * Take scanner input and set that for the limit of the array length.
- * Then run a loop to print out the numbers that have been put into the array.
- */
- public class Constructor {
- public Constructor (int testInput){
- //Int. the array
- final int LIMIT = testInput;
- int[] Test = new int[LIMIT];
- for(int loop = 0; loop<LIMIT; loop++){
- Test[loop] = loop;
- }
- for (int i=0; i<LIMIT; i++)
- System.out.print (Test[i] + " ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement