Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- int[][] array2D = new int[8][16];
- File arrayFile = new File("Array File.txt");
- for (int i = 0; i < array2D.length; i++) {
- for (int j = 0; j < array2D.length; j++) {
- array2D[i][j] = (int) (1 + Math.random() * 100);
- }
- arrayToString(array2D,arrayFile);
- }
- }
- static void arrayToString(int[][] array, File file){
- try(PrintWriter pw = new PrintWriter(file)){
- for(int i = 0; i < array.length; i++){
- for(int j = 0; j < array.length; j++){
- pw.print(array[i][j]+"\t");
- }
- pw.println();
- }
- }catch (IOException e){
- e.printStackTrace();
- System.out.println("Pay Attention!");
- }
- }
- }
Add Comment
Please, Sign In to add comment