Swap two Strings without using temp/third variable - Java Interview Questions -9

preview_player
Показать описание
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,

3) call the method substring(int beginindex) by passing
b string in a

====================================================
Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:

Follow me on my Facebook Page:

Let's join our Automation community for some amazing knowledge sharing and group discussion:

Follow me on my Facebook Page:

Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:

Paid courses (Recorded) videos:
📗 Get My Paid Courses at
Paid courses (Recorded) videos:
-------------------------------

✔️SOCIAL NETWORKS
--------------------------------

Support My Channel✔️Or Buy Me A Coffee
--------------------------------
✔️Thanks for watching!
देखने के लिए धन्यवाद
Благодаря за гледането
感谢您观看
Merci d'avoir regardé
Grazie per la visione
Gracias por ver
شكرا للمشاهدة
Рекомендации по теме
Комментарии
Автор

Seen some of your videos.. There are other YouTuber who explained these concepts But Must say this - The way you explain, is extraordinary, it just get typed into memory ( human Lol) and never get erased

nibeditajinu
Автор

one more:
s1=s1+s2;
s2=s1.replace(s2, "");
s1=s1.replace(s2, "");

ckumar
Автор

Hi Naveen,
Your videos are amazing and worth watching. It gives more confidence to viewers and helps a lot to attend any interviews and apply this concept in real projects. Your framework videos are just WAW! and your way of breaking and explaining the concepts is beautiful. My best wishes to you.

soumyacc
Автор

I wrote little different logic by using strip function in Python and it worked.
#Swap StringsPython

a = "hello"
b = "world"
print(a, b)
a = a+b
difflength= len(a) - len(b)
b = a[0:(difflength)]
a = a.strip(b)
print(a, b)

sahilkhenat
Автор

How many “thank you “ is enough for your efforts? Lol thank you from my deep heart

uyghurfilms
Автор

More interview java videos will be useful.your approach is very easy to understand.

hi-ksrl
Автор

Thank you Naveen for your efforts.
Solution of above using replace function
String s1 = "Hello";
String s2 = "World";
// Using replace
s1 = s1.concat(s2);
s2 = s1.replace(s2, "");
s1 = s1.replace(s2, "");
System.out.println(s1 +" | "+s2);

pradeepb
Автор

Amazing explanation, thank you Naveen

artimandale
Автор

Hi Neveen,
Thank you for your time. All videos are very useful.

durdonatursunova
Автор

helpful tutorial, thank you, keep it up 👍👍👍👍

SmartProgramming
Автор

Thank you Naveen, it's really helpful

priyankagoel
Автор

one more



String a= "akash"

String b= "Gaurav"



System.out.println("The new value of a will be " + b.Substring(0) );


System.out.println("The new value of b will be " + a.Substring(0) );

gauravakash
Автор

Can you please explain a program which is checking the drop down string values are in alphabetical order?

clearaj
Автор

Why css selector is faster than xpath, if it is fast why most of the automation engieers are preferred to write mostly custom xpath in place of custom css selectors

sunilreddymallela
Автор

One More Way ;-)


String a = "Hello";
String b = "World";


System.out.println("A: "+a);
System.out.println("B: "+b);

a = a+b;
b=a.substring(0, 5);
a=a.substring(5, 10);

System.out.println("A after swapped from Hello to: "+a);
System.out.println("B after swapped from World to: "+b);

samshoaib