Created
August 31, 2015 23:19
-
-
Save jweinst1/ccf1dab602fd3a4621b2 to your computer and use it in GitHub Desktop.
produces an array of a certain length of integers in java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| class Main { | |
| public static void main(String[] args) { | |
| System.out.println(Arrays.toString(range(4))); | |
| } | |
| static int[] range(int x) { | |
| int [] range = new int[x]; | |
| int num = 0; | |
| while (num < x) { | |
| range[num] = num; | |
| num++; | |
| } | |
| return range; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment