Understanding pass-by-value - Java Object Oriented Design

Java examples for Object Oriented Design:Method Parameter

Description

Understanding pass-by-value

Demo Code

public class ChangeParameters
{
     public static void main(String[] args)
      {/*from ww w  .j  a  va 2  s .co  m*/
           int number = 1;
           tryToChangeNumber(number);
           System.out.println(number);

      }

     public static void tryToChangeNumber(int i)
      {
           i = 2;
      }
}

Related Tutorials