I can't assign a specific char like "X" in part of my input string. For example I want to assign a default char with substring method in specific range of my input string. How can I assign a specific char in specific range of my input string.
Can you help me?
import java.util.*;
public class Algoproject {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
while(true){
int num=input.nextInt();//number of colums
if(num!=0) {
String s;
s=input.next();//enter string without space
int count=s.length();//string length
displayMessage(s,num,count);
}else
break;
}
}
public static void displayMessage(String str, int pi,int slength){
int j=0,i=pi;
while(pi<=slength){
System.out.print(str.substring(j,pi )+"\n");
j=pi;
pi=pi+i;
}
System.out.print(str.substring(j,slength ));
String in="$";
//line29
}}
in line 29 I want a method that give 3 value:
- my arbitrary char
- first index of my string
- last index of my string
and I want to assign that char in this string range