How to Access Class Methods with an Object in Java


In this example we will show the method to access class methods with an object in Java.

Source Code

package com.beginner.examples;

public class Message {
 
  public void Info() {
    System.out.println("It is good!");
  }

  public static void main(String[] args) {
    Message m = new Message(); // new Message
    m.Info(); // access class methods
  }
}

Output:

It is good!
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments