JAVA – Calling methods in the same class

This sample shows how to call methods in the same class using JAVA coding.

Code:

/* CallingMethodsInSameClass.java
*
* illustrates how to call static methods a class
* from a method in the same class
*/

public class CallingMethodsInSameClass
{
public static void main(String[] args) {
printOne();
printOne();
printTwo();
}

public static void printOne() {
System.out.println(“Hello World”);
}

public static void printTwo() {
printOne();
printOne();
}
}

Code Flavour is a news site with a focus on coding. Our aim is deliver news over a range of categories which will be insightful and beneficial to readers that are interesting in code development.

You may also like...

Leave a Reply

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