Functions

In Java, as in C and C++, we have 2 types of functions:

Format for a void function: 

public static void function_name(parameter list) 
{ 
	//statements go here 
} 


Format for a return function: 
public static type_name function_name(parameter list) 
{ 
	//statements go here return some_value; 
} 
Questions:

1) If we are writing a function to print a series of instructions to the user, which type of function would we use?
2) If we are writing a function to calculate sales tax, which type of function would we use?

Click here to return to the IT 108 page


Copyright © 1999-2002 by Anne Marchant, all rights reserved.