Thursday, 29 October 2015

Interchange two values with third variable

Interchange two values with third variable
  • Make new jFrame and add the components to frame like given in below figure.



  • Open source code and declear three variables a,b,c as integer and also type the code of text fields.
  • Type the code given below 
  • Now I will explain how java interchanges the value:
  1. Let a=10,b=20,c=0.
  2. Here c=a means c=10.
  3. Now a=0.
  4. Then a=b means a=20.
  5. Now b=0.
  6. Then b=c means b=10.
  7. So by this java interchanges the value.
  • Now print a & b.
  • Run the file and see what happens.

No comments:

Post a Comment