Home / Questions / What is the syntax of a Java function?
Explanatory Question

What is the syntax of a Java function?

👁 5 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation


accessModifier returnType methodName(parameters) {
    // method body
}

Example::


public int add(int a, int b) {
    return a + b;
}