/* Author : Michael Robinson Program : returnDataProgram.java Purpose : To show how to to return data to the calling statement. Updated : January 14, 2099 */ public class returnDataProgram { //Calls method myInfo1 passing myName and myID and //expects data to be returned to the int result variable public static int myInfo1( String name, int myID ) { System.out.print( "\nHi I am at myInfo1\n" ); System.out.printf( "My name is : %s My ID is : %d\n", name, myID ); System.out.printf( "returning to main() %d * 2 to be" + " printed\n", myID ); return( myID * 2 ); }//end public static int myInfo1 //calls method NOT passing data to myInfo2 //and expects data to be returned to the int result variable public static int myInfo2() { System.out.print( "\nHi I am at the public static int " + "myInfo2() method\n" ); System.out.print( "returning the value 999 which will " + "be printed at main\n" ); return( 999 ); }//end public static int myInfo2() public static void main( String arg[] ) { int myID = 777; //create variable myID with value 777 String name = "Michael"; //create name value Michael //methods can return data to calling statement as follows: int result1 = myInfo1( name, myID ); System.out.printf( "\nAt main() received %d\n", result1 ) ; //calls method NOT passing data to myInfo2 int result2 = myInfo2(); System.out.printf( "\nAt main() received %d\n\n" , result2 ); }//end public static void main( String arg[] ) }//end public class returnDataProgram