Assign other value to a variable from two possible values | Java program to change value of x according to its current value . ; Function to alternate the values ; Main function
import java . util . * ; class solution { static void alternate ( int a , int b , int x ) { x = a + b - x ; System . out . println ( " After ▁ change " + " " + " x is : "+x); } public static void main ( String args [ ] ) { int a = - 10 ; int b = 15 ; int x = a ; System . out . println ( " x ▁ is ▁ : ▁ " + x ) ; alternate ( a , b , x ) ; } }