+ 1

how to convert a string s="INDIABIX" to "IDNIAIBX"

23rd Sep 2016, 1:01 PM
Nitish Thukral
Nitish Thukral - avatar
4 Answers
+ 3
string s ="INDIABIX"; string temp; temp[0] =s[1]; s[1]=s[2]; s[2]=temp[0];//now s is IDNIAIBX take a look http://uupload.ir/files/n5l_j.png
19th Dec 2016, 8:42 PM
Navid Tak
Navid Tak - avatar
+ 1
See how "replace" can be used: http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#replace(java.lang.CharSequence,%20java.lang.CharSequence)
24th Sep 2016, 7:24 AM
Igor
0
public class sm { public static void main(String[] args) { String g="INDIABIX"; char[] s=g.toCharArray(); char temp; temp=s[1]; s[1]=s[2]; s[2]=temp; temp=s[5]; s[5]=s[6]; s[6]=temp;//IDNIAIBX System.out.println(s); } }
24th Sep 2016, 6:41 AM
மனோஜ்குமார் பழனிச்சாமி
மனோஜ்குமார் பழனிச்சாமி - avatar
- 1
it will change n to d only
23rd Sep 2016, 3:41 PM
Nitish Thukral
Nitish Thukral - avatar