Functions are "self contained" modules of code that accomplish a specific task. Functions usually "take in" data, process it, and "return" a result. Once a function is written, it can be used over and over and over again. Functions can be "called" from the inside of other functions.
In Java, all function definitions must be inside classes. We also call functions methods. Let's look at an example method
public class Main {
public static void foo() {
// Do something here
}
}
Comments
Leave a comment