public class PassByValue  {
/*
 * The following routine shows that pass by value does
 * not affect value of the argument passed by the calling
 * program.
 */
   public static void main(String[] args)  {
           int num=100;
           increment(num);
           System.out.println("After calling increment, num is " + num);
   }

   public static void increment(int n) {  
        n++; 
        System.out.println ("Inside increment, n is " + n);
        return;
   }
                                                                    }

© 2012 CS160 Colorado State University. All Rights Reserved.