Sometime, we need to remove or replace some particular character from a String.
Below is the method by which we can accomplish this. I am using replaceAll() method of the String.
replaceAll() have two parameter as an arguments. First one is the list of character that you want to
replace and second is the string that you want to be replace with.
String name = Ja(v_)-a;
name = name.replaceAll([-)_(],);
System.out.println(New String : +name);
O/P:
New String :Java
Exception is ^ character cannot be the first character of the list.
Hope it will help you.
0 Comment(s)