Back To Java User Defined Methods Index
//program to create a function that returns volume of box based on width,depth and height passed to function as integer arguments class volumebox { public int volume(int width,int depth,int height) { int vol; vol=width*depth*height; return vol; } } public class voumeboxreturn { public static void main(String[] args) { volumebox ob=new volumebox(); int result; result=ob.volume(10,20,30); System.out.println("volume of box is " + result); } }