Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java string swap two characters

String originalString = "abcde";
//Strings are immutable
char[] c = originalString.toCharArray(); 
//Swap
char temp = c[0];
c[0] = c[1];
c[1] = temp;
//Result
String swappedString = new String(c);
Comment

PREVIOUS NEXT
Code Example
Java :: mockito verify not called 
Java :: java string array 
Java :: how to make an activity default in android studio 
Java :: spigot respawn player location 
Java :: java how to print 
Java :: java get random char 
Java :: hanoi tower java 
Java :: java prime 
Java :: android hide system bar programmatically 
Java :: how to calculate the amount of months between two dates java 
Java :: how to check my java heap space size 
Java :: how to know java version in cmd 
Java :: add seconds to today date and time java 
Java :: display an image java 
Java :: java or symbol 
Java :: java remove duplicates from list by property 
Java :: sort list of strings java 
Java :: how to read a json file in java 
Java :: android splash screen 
Java :: java import text file into arraylist 
Java :: java ioexception 
Java :: get username from jwt token request spring boot 
Java :: change button text onclick javca 
Java :: select max value from list java 
Java :: java go troght loop object 
Java :: java return list 
Java :: select in selenium java 
Java :: date difference in minutes java 
Java :: Do not concatenate text displayed with setText. Use resource string with placeholders. 
Java :: java cast int to string 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =