How to replace Digits into String using Java?
Answers
Answered by
0
1.To convert an integer to string, we use the Integer.toString()function.
Ex:
int a=5;
String b=Integer.toString(a);
//now b="5"
System.out.println(b);//prints 5
2.To do the opposite, we use Integer.parseInt() function
Ex:
String a="5";
int b=Integer.parseInt(a);
//now b=5
System.out.println(b);//prints 5
Answered by
1
Answer:
Java uses a replace function that returns characters :---
Syntax :- String stringname =String.replace('m' ,'n');
m= the charactera in string that is to be replaced.
n=the characters that are replaced by this character.
Example:--
String a="Bαnana";
String t=a.replace('a','e');
System.out.println(t);
OUTPUT :-- Benene
Similar questions
India Languages,
6 months ago
English,
6 months ago
Hindi,
6 months ago
Computer Science,
1 year ago
Math,
1 year ago
Math,
1 year ago