0
What is the difference between replace and replaceAll? JAVA
Hello everyone I want to know what is the difference between replace and replaceAll in java when they do the same things in the ex. String s1 = "Hello everyone"; String s2 = "My name was Abgar was..."; replaceString1 = s1.replace('e', 'a'); replaceString2 = s2.replace("was", "is"); replaceAllString1 = s1.replaceAll("e", "a"); replaceAllString2 = s2.replaceAll("was", "is"); System.out.println(replaceString1); //Hallo avarona System.out.println(replaceString2); //My name is Abgar is... System.out.println(replaceAllString1); //Hallo avarona System.out.println(replaceAllString2); //My name is Abgar is...
1 Resposta