fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Boolean[][] squaresWithPieces = new Boolean[][]{
  13. { Boolean.TRUE, null, Boolean.FALSE },
  14. { Boolean.FALSE, null, Boolean.TRUE },
  15. };
  16.  
  17. System.out.println( "-----| Boolean Formatter |---------" ) ;
  18. for (int row = 0; row < squaresWithPieces.length; row++) // Cycles through rows.
  19. {
  20. for (int col = 0; col < squaresWithPieces[row].length; col++) // Cycles through columns.
  21. {
  22. System.out.printf("%5b ", squaresWithPieces[row][col]); // Change the %5d to however much space you want.
  23. }
  24. System.out.println("") ;
  25. }
  26.  
  27. System.out.println( "-----| String Formatter |---------" ) ;
  28. for (int row = 0; row < squaresWithPieces.length; row++) // Cycles through rows.
  29. {
  30. for (int col = 0; col < squaresWithPieces[row].length; col++) // Cycles through columns.
  31. {
  32. System.out.printf("%5s ", squaresWithPieces[row][col]); // Change the %5d to however much space you want.
  33. }
  34. System.out.println("") ;
  35. }
  36.  
  37. System.out.println( "\n\n" ) ;
  38. }
  39. }
Success #stdin #stdout 0.1s 48164KB
stdin
Standard input is empty
stdout
-----|  Boolean Formatter  |---------
 true false false 
false false  true 
-----|  String Formatter  |---------
 true  null false 
false  null  true