You are on page 1of 1

public class MethodExamples {

public static void main (String [] args)


{
// To call a method, write its name, including any
// input values ("arguments") inside the parentheses
// (note that method names are always followed by parentheses,
// even if the method does not take any input). If the method
// returns a value, you can save that result into a new variable
.
double product = multiply(3, 5);
System.out.println(product);
message("This is some sample text");
int val = four();
System.out.println(val);
printHeader();
}
// Input and output
public static double multiply (double first, double second)
{
return first * second;
}
// Input, no output (only side effects)
public static void message (String msg)
{
System.out.println(msg);
}
// No input, but output
public static int four ()
{
return 4;
}
// No input, but output
public static String line ()
{
return "********";
}
// No input, no output (only side effects)
public static void printHeader()
{
System.out.println("<html>");
System.out.println("<head>");
System.out.println("</head>");
System.out.println("<body>");
}
}

You might also like