Functions: greeting + farewell Learn programming Java

Lesson:

Functions


Exercise:

Functions: greeting + farewell 42


Objetive:

Create a program whose Main must be like this:

public static void Main()
{
SayHello();
SayGoodbye();
}

SayHello and SayGoodbye are functions that you must define and that will be called from inside Main.


Code:

public class Main
{
	public static void SayHello()
	{
		System.out.println("Hello!");
	}

	public static void SayGoodbye()
	{
		System.out.println("Good Bye!");
	}

	public static void main(String[] args)
	{
		SayHello();
		SayGoodbye();
	}
}