Selenium Real time Interview Questions || Swap two Strings without using temp/third variable

Опубликовано: 16 Февраль 2026
на канале: Selenium Automation Testing
521
11

Swap two Strings without using temp/third variable:

Algorithm:

1) Append second string to first string and
store in first string:
a = a + b

2) call the method substring(int beginindex, int endindex)
by passing beginindex as 0 and endindex as,
a.length() - b.length():
b = substring(0,a.length()-b.length());

3) call the method substring(int beginindex) by passing
b.length() as argument to store the value of initial
b string in a
a = substring(b.length());
======================================================
Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:    / @seleniumautomationtesting7617  
=======================================================
Selenium Framework with Page Object Model | E-Commerce Project
   • Selenium Framework with Page Object Model ...  
=========================================================