Skip to content

Instantly share code, notes, and snippets.

@xnorcode
Last active Aug 29, 2018
Embed
What would you like to do?
Simple Array Manipulation in Java
...
// Method 1
// create array of already known numbers
int[] numbers = {10,2,5,8,37,6};
// printing all numbers
for(int i = 0; i < numbers.length; i++){
System.out.println(numbers[i]);
}
// Method 2
// create an empty array with 3 slots
String[] strings = new String[3];
// input strings to the array
for(int i = 0; i < 3; i++){
strings[i] = "String"+i;
}
// printing the strings
for(String s : strings){
System.out.println(s);
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment