I was trying to make something then i couldn't write an if method with contains and replace method. What was i missing?
import java.util.Scanner;
public class replacesomething
{
public static void main(String[] args)
{
Scanner cumle = new Scanner(System.in);
System.out.println("Enter the sentence u want to replace ");
String str1 = cumle.next();
if (str1.contains("replace"))
{
str1.replace("replace", "Hi");
System.out.println("Replaced Sentence: " + str1);
}
else
{
System.out.println("Sentence doesn't contains that...");
}
}
}