answersLogoWhite

0

A java method is a series of statements that perform some repeated task. Instead of writing 10 lines of code we can put those ten lines in a method and just call it in one line. It is like a shortcut.

For example if we had to repeatedly output a header such as: System.out.println("Feral Production");

System.out.println("For all your Forest Videos");

System.out.println("427 Blackbutt Way");

System.out.println("Chaelundi Forest");

System.out.println("NSW 2473");

System.out.println("Australia");

We could put it all in a method like this: public static void printHeader(){

System.out.println("Feral Production");

System.out.println("For all your Forest Videos");

System.out.println("427 Blackbutt Way");

System.out.println("Chaelundi Forest");

System.out.println("NSW 2473");

System.out.println("Australia");

}

And to call it we simply write: printHeader();

And it will print out:

Feral Productions

For all your Forest Videos

427 Blackbutt Way

Chaelundi Forest

NSW 2473

Australia

Java methods provide us with features to pass arguments to it and also return values from it.

User Avatar

Wiki User

16y ago

What else can I help you with?