How to use arrays of integers in Java; also some stuff on the important difference between values and references.
When the video is running, click the maximize button in the lower-right-hand corner to make it full screen.
Code for this tutorial:
public class App {
public static void main(String[] args) {
int value = 7;
int[] values;
values = new int[3];
System.out.println(values[0]);
values[0] = 10;
values[1] = 20;
values[2] = 30;
System.out.println(values[0]);
System.out.println(values[1]);
System.out.println(values[2]);
for(int i=0; i < values.length; i++) {
System.out.println(values[i]);
}
int[] numbers = {5, 6, 7};
for(int i=0; i < numbers.length; i++) {
System.out.println(numbers[i]);
}
}
}
0 10 20 30 10 20 30 5 6 7
Learn to program Java Swing with my complete video course – desktop programming and applets. Includes 7 free videos. Click here for details.
All pages on this site are copyright © 2013 John W. Purcell