I noticed that in OCaml we are allowed to use currying function like
let add = 
    fun y -> (fun x -> x + y)  
;;
But my professor stated that this kind of format is not allowed in Java. For example, given a method foo1, it is possible to have foo1 returns when foo2 is executing. Is it a valid explanation? If not, what leads to this difference between Java and OCaml?
int foo1(int a, ...) {
    int foo2(...) {
        //main body         
    }
}
 
     
     
    