Start learning free

LESSON 39 OF 671 · FUNCTIONS I

Exercise: Create Function with Parameters in Java

Practice

We've written this code:

void mainFunction() {
	System.out.println("My name is Andy");
	System.out.println("I code in Python");
	System.out.println("I have a dog");

	System.out.println("My name is Mike");
	System.out.println("I code in Java");
	System.out.println("I have a cat");

	System.out.println("My name is Sarah");
	System.out.println("I code in JavaScript");
	System.out.println("I have a parrot");
}

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

STEP 1 OF 5
    Ctrl + Enter to check