This shows you the differences between two versions of the page.
— |
java:lang:string:replace [2024/02/16 01:12] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== replace ====== | ||
+ | <code java> | ||
+ | public String replace(CharSequence target, CharSequence replacement) | ||
+ | </code> | ||
+ | ===== description of replace ===== | ||
+ | this method is used to replace a char Sequence | ||
+ | |||
+ | ==== example of replace in java ==== | ||
+ | <code java> | ||
+ | package replace; | ||
+ | |||
+ | public class ReplaceString { | ||
+ | |||
+ | public static void main(String[] args) { | ||
+ | |||
+ | String str = "Hello"; | ||
+ | |||
+ | str = str.replace("el", "xx"); | ||
+ | System.out.println("String after replacement :"+ str ); | ||
+ | |||
+ | |||
+ | } | ||
+ | } | ||
+ | |||
+ | </code> | ||
+ | |||
+ | === output of replace example in java === | ||
+ | |||
+ | String after replacement :Hxxlo | ||
+ | |||
+ |