Guest User

Untitled

a guest
Dec 25th, 2012
208
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. public class Demo {
  3.     public static void main(String args[]) {
  4.         // matrix will contain generated odd and even integers
  5.         int matrix[][] = new int[2][];
  6.         for (int i=0;i<2;i++) {
  7.             // populating odd / even integer array
  8.             int tmpArray[] = new int[5];
  9.             for (int j=0;j<tmpArray.length;j++) {
  10.                 tmpArray[j] = 2*(j+1) + 1*i;
  11.             }
  12.             matrix[i] = tmpArray;
  13.         }
  14.        
  15.         int dummyIntArray[] = new int[1];
  16.         dummyIntArray[0] = -1;
  17.        
  18.         // Get and print an integer stored in dummyIntArray.
  19.         int myInt = dummyIntArray[0];
  20.         System.out.println("Dummy Integer: " + myInt);
  21.    
  22.         // Get and print odd integers stored in matrix.
  23.         Object oddIntegersObj = matrix[1];
  24.         printIntegerArray("Odd Integers:", (int [])oddIntegersObj);
  25.        
  26.         // Get and print even integers stored in matrix.
  27.         Object evenIntegersObj = matrix[0];
  28.         printIntegerArray("Even Integers:", (int [])evenIntegersObj);
  29.     }
  30.    
  31.     private static void printIntegerArray(String text, int array[]) {
  32.         if (array != null) {
  33.             System.out.println(text);
  34.             for (int j=0;j<array.length;j++) {
  35.                 System.out.print(array[j] + " ");
  36.             }
  37.             System.out.println();
  38.         }
  39.     }
  40. }
RAW Paste Data