Pass function as parameter, JAVA : Have to port a little piece of code from JavaScript to JAVA:

    var N = 3;
    var w = 8, h = 8;
    
    var matrix = [ 
    
                   [1, 0, 0, 0, 0, 0, 0, 0],
                   [1, 1, 0, 0, 0, 0, 0, 0],
                   [1, 1, 1, 0, 0, 0, 0, 0],
                   [1, 1, 1, 1, 0, 0, 0, 0],
                   [1, 1, 1, 1, 1, 0, 0, 0],
                   [1, 1, 1, 1, 1, 1, 0, 0],
                   [1, 1, 1, 1, 1, 1, 1, 0],
                   [1, 1, 1, 1, 1, 1, 1, 1]
    
                 ];
     
    //[1, 1, 1, 1, 1, 1, 0, 1, 1]
    console.log(complexFunction(2, 1));
     
    //first function
    function simpleFunction(f_) {
    
        var out = new Array(N * N);
    
        for (var y = 0; y < N; y++) {
            for (var x = 0; x < N; x++) {
    
            out[x + y * N] = f_(x, y);
    
            }
        }
    
        return out;
    
    };
       
    //second function     
    function complexFunction(x_, y_) {

        return simpleFunction(function (dx, dy) { return matrix[(x + dx) % w][(y + dy) % h]; });
                
    };

Have experimented with Callable without any success. 
Ideally, the ported result should have the same structure as JavaScript source.