String x = "axe pickaxe";
x = x.replace("axe", "sword");
System.out.print(x);
By this code, I am trying to replace the exact word axe with sword. However, if I run this, it prints sword picksword while I would like to print sword pickaxe only, as pickaxe is a different word from axe although it contains it. How can I fix this? Thanks