/* * ================================================================= * DemoTryChange.java: The programa shows how the pass-by-value * mechanism works in java. * * Written By: Mark Austin October 2005 * ================================================================= */ import java.lang.Math; import java.text.*; public class DemoTryChange { // main method : this is where the program execution begins. public static void main ( String [] args ) { int i; // [a] Test passing of variable to a method.... i = 1; System.out.println("*** In main(): i = " + i); System.out.println("*** Call TryChange()...."); TryChange( i ); System.out.println("*** Back in main(): i = " + i); } // Simple method to demonstrate call-by-value mechanism.... static void TryChange( int i ) { // Print value of variable passed to TryChange().... System.out.println("*** In TryChange(): i = " + i); // Change value of i and print new value ..... i = 3; System.out.println("*** In TryChange(): i = " + i); } }