Skip to content

Commit e814ff5

Browse files
committed
Challenge 32.
String and immutability.
1 parent 696a7cd commit e814ff5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package challenge31_40;
2+
3+
/**
4+
* unlike StringBuilder, String are immutable.
5+
*/
6+
public class Challenge_32 {
7+
public static void main( String[] args ) {
8+
var jedi = "masterYoda";
9+
changeString(jedi);
10+
System.out.println(jedi);
11+
}
12+
13+
private static String changeString( String word ) {
14+
word.replace(word, "newMasterYoda");
15+
return word;
16+
}
17+
}

0 commit comments

Comments
 (0)