0
Swap variables without introducing third variable
Int a=5; Int b= 6; How will you swap the variables ?(a=6, b=5)
7 Answers
+ 9
a=a*b
b=a/b
a=a/b
+ 5
Use this trick..
If u want to swap a and b.,
a=a+b;
b=a-b;
a=a-b;
You will get it
+ 4
It's simple addition and subtraction, just play with those numbers and you will end up getting the answer.
+ 3
LearnerLipi
Using substrings.
https://code.sololearn.com/cqZ3G8zCI0jI/?ref=app
+ 2
I'm sure you'll find some examples online, have you searched on google ?
+ 2
Strings are immutable and you can update the same variable with new values but remember every time you do that, you will create a new object.
+ 1
Avinesh : What when it's string?