Guest User

Untitled

a guest
Jan 17th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. public class Main {
  2. public static void main(String[] args) {
  3. int[][] array2D = new int[8][16];
  4. File arrayFile = new File("Array File.txt");
  5. for (int i = 0; i < array2D.length; i++) {
  6. for (int j = 0; j < array2D.length; j++) {
  7. array2D[i][j] = (int) (1 + Math.random() * 100);
  8. }
  9. arrayToString(array2D,arrayFile);
  10. }
  11. }
  12. static void arrayToString(int[][] array, File file){
  13. try(PrintWriter pw = new PrintWriter(file)){
  14. for(int i = 0; i < array.length; i++){
  15. for(int j = 0; j < array.length; j++){
  16. pw.print(array[i][j]+"\t");
  17. }
  18. pw.println();
  19. }
  20. }catch (IOException e){
  21. e.printStackTrace();
  22. System.out.println("Pay Attention!");
  23. }
  24. }
  25. }
Add Comment
Please, Sign In to add comment