Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ArraysDay2{
- public static void main(String[] args){
- //Declare and Initialize on separate lines
- int[] randomInts = new int[200];
- System.out.println( randomInts[55] );
- for( int i = 0; i < randomInts.length; i++ ){
- randomInts[i] = (int)(Math.random() * 10 + 1);
- }
- System.out.println( randomInts[157] );
- //Parallel arrays
- String[] actors = {"Zac Efron" , "Zoe Saldana" , "Johnny Depp"};
- String[] movies = {"High School Musical" , "Guardians of the Galaxy", "Charlie and the CF"};
- for( int i = 0; i < actors.length; i++ )
- System.out.println("My favorite " + actors[i] + " movie is " + movies[i]);
- //Pass by value/reference
- int i = 3;
- int[] iArr = {7, 41, 52, 8};
- doSomething(i, iArr);
- System.out.println( i + " " + iArr[3] );
- }
- public static void doSomething( int j, int[] jArr ){
- j = 99;
- jArr[3] = 88;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement