Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 30th, 2012  |  syntax: Java  |  size: 1.45 KB  |  views: 43  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.util.Arrays;
  2.  
  3. public class ClassA {
  4.     private static ClassB[][] classB_2Array;
  5.  
  6.     public static void main(String[] args) {
  7.         classB_2Array = new ClassB[10][10];
  8.  
  9.         for (ClassB[] classB_1Array : classB_2Array) {
  10.             Arrays.fill(classB_1Array, new ClassB());
  11.         }
  12.         classB_2Array[1][1].filledWithAsterix = true;
  13.         print();
  14.  
  15.         classB_2Array = new ClassB[10][10];
  16.         System.out.println();
  17.  
  18.         for (int i = 0; i < classB_2Array.length; i++) {
  19.             for (int j = 0; j < classB_2Array[0].length; j++) {
  20.                 classB_2Array[i][j] = new ClassB();
  21.             }
  22.         }
  23.  
  24.         classB_2Array[1][1].filledWithAsterix = true;
  25.         print();
  26.     }
  27.  
  28.     private static void print() {
  29.         for (int i = 0; i < classB_2Array.length; i++) {
  30.             for (int j = 0; j < classB_2Array[0].length; j++) {
  31.                 System.out.print(classB_2Array[i][j].getMark());
  32.             }
  33.             System.out.println();
  34.         }
  35.     }
  36. }
  37.  
  38. class ClassB {
  39.  
  40.     public boolean filledWithAsterix = false;
  41.  
  42.     public String getMark() {
  43.         if (!filledWithAsterix)
  44.             return "*";
  45.         return "F";
  46.     }
  47. }
  48.  
  49. /*
  50. **********
  51. FFFFFFFFFF
  52. **********
  53. **********
  54. **********
  55. **********
  56. **********
  57. **********
  58. **********
  59. **********
  60.  
  61. **********
  62. *F********
  63. **********
  64. **********
  65. **********
  66. **********
  67. **********
  68. **********
  69. **********
  70. **********
  71. */
clone this paste RAW Paste Data