public String addChar(String str, char ch, int position) {
return str.substring(0, position) + ch + str.substring(position);
}
char ch='A';
String str="pple";
str= ch+str; // str will change to "Apple"
public class JavaHungry {
public static void main(String args[]) {
char ch = 'J';
String str = "avaHungry";
//Adding character at the beginning
str = ch + str;
System.out.println(str);
}
}
1. String otherString = "helen" + character;
2. otherString += character;