Monday, April 30, 2018

Swap two variables using third variable !

  1. public class SwapTwoNumberWithThirdVariable {
  2. public static void main(String[] args) {
  3. int a = 10;
  4. int b = 20;

  5. int temp;
  6. temp = a;
  7. a = b;
  8. b = temp;
  9. System.out.println("after swap value of a: " + a);
  10. System.out.println("after swap value of b: " + b);
  11. }
  12. }
Output: 
after swap value of a: 20
after swap value of b: 10

No comments:

Post a Comment

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...