Start learning free

LESSON 34 OF 671 · FUNCTIONS I

Exercise: Create Function in Java

Practice

We've wrritten this code:

void mainFunction() {
	System.out.println("Hello AlgoCademy!");
	System.out.println("Coding is amazing!");
	System.out.println("Functions are so useful!");

	System.out.println("Hello AlgoCademy!");
	System.out.println("Coding is amazing!");
	System.out.println("Functions are so useful!");

	System.out.println("Hello AlgoCademy!");
	System.out.println("Coding is amazing!");
	System.out.println("Functions are so useful!");
}

Write the same code in a better way by creating and calling a function printMessages()

STEP 1 OF 5
    Ctrl + Enter to check