how to change a character in a string in java with ascii
// From Char to Ascii
char character = 'a';
int ascii = (int) character;
// From Ascii to Char
int ascii = 65;
char character = (char) ascii;
how to change a character in a string in java with ascii
// From Char to Ascii
char character = 'a';
int ascii = (int) character;
// From Ascii to Char
int ascii = 65;
char character = (char) ascii;
how to change the character of a string in java
// You cannot change the characters of a string in java
// But you can make it work
// For Example: A Program to change 'r' to 'a'
class Main{
public static void main(String args[]){
String str = "return";
String res = "";
for(int i = 0; i<str.length(); i++){
if(str.charAt(i)=='r'){
res+='a';
}
else{
res+=str.charAt(i);
}
}
System.out.print("Result = "+res);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us