Computer Science, asked by preet7778, 1 year ago

How to use Java string replace method?

Answers

Answered by amannishad0512p5zxh6
0

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="Banana";

String t=a.replace('a','e');

System.out.println(t);

OUTPUT :-- Benene

Hope it will help you@

Mark me brainlest and follow me to solve more doubts

Answered by Ᏸυէէєɾϝɭყ
1

Answer:

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

Similar questions