generate a 2d array that could be used to create an image with Java

This Python code

im_data = np.ones((100,100))
im_data(20:50,20:50)=np.zeros((30,30))

can generate a 2d array that could be used to create an image

plt.axis('off')
axi = plt.imshow(im_data, cmap='Greys')

enter image description here

I’m trying to do the same job with Java

class Arr100{
    public static void main(String() args){
        System.out.println("H");
        int()() arr = new int(100)(100);
        for(int i=0; i<arr.length; i++){
            for (int j=0; j<arr(i).length; j++){
                arr(i)(j)=1;
            }
        }
        for(int i=20; i<50; i++){
            for (int j=20; j<50; j++){
                arr(i)(j)=0;
            }
        }
    }
}

In terms of GPU and memory, is there a better way to do the same thing?