How to Create and Call a Method in Java


In this example, we will learn the method to create and call a method in Java.

Source Code

package com.beginner.examples;

public class CreateAMethod {
  static void test() {
    System.out.println("ok");
  }

  public static void main(String[] args) {
    test(); // call the method
  }
}

Output:

ok
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments