Categories
Core JAVA

Core Java Tutorial – JournalDev

[]
Sai Krishna says:

Hi,

I surfed the web and came to know about Journaldev and started following your materials to learn Java. I found the content really simple in an easily understandable way.

While going through the following program from this link (https://www.journaldev.com/22385/java-method)

package com.journaldev.util;

public class MathUtils {

public int add (int x, int y) {
return x + y;
}

public static void main(String args[]) throws Exception {
MathUtils mu = new MathUtils();
System.out.println(mu.add(5, 2));
MathUtils.print(“Static Method”);
}

public static void print(String s) {}

}

I’ve few doubts, can you please clarify them. Why did we use these methods in our program 1) MathUtils.print(“Static Method”); and 2) public static void print(String s) {}

Without these lines also I’m getting the same output. Can you please let me know the reason we’re using this.

Thankyou

Source

Leave a Reply

Your email address will not be published. Required fields are marked *