Skip to content

Instantly share code, notes, and snippets.

@jweinst1
Created August 31, 2015 23:19
Show Gist options
  • Select an option

  • Save jweinst1/ccf1dab602fd3a4621b2 to your computer and use it in GitHub Desktop.

Select an option

Save jweinst1/ccf1dab602fd3a4621b2 to your computer and use it in GitHub Desktop.
produces an array of a certain length of integers in java
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