Hi...! i wan to write a program that when i give it a number and a string it replace string with length=number to "1,2...,n" but its replace part doesn't work!
this is the code:

package fasle5;

import java.util.Scanner;

public class Tamrine8 {
    public static void main(String args[]){
        System.out.println("Enter N:");
        Scanner input =new Scanner(System.in);
        int n=input.nextInt();
        System.out.println("Enter String:");
        Scanner input1 =new Scanner(System.in);
        String str=input1.nextLine();
        String s=new String();
        for(int i=1;i<=n;i++)
        String string[]=str.split(" ");
        for(int j=0;j<string.length;j++)
                string[j].replace(string[j].substring(j, n), s);
                System.out.println(string[j].substring(j, n));

        for(int k=0;k<string.length;k++)

what is the problem?

I can't understand your description of the requirement! Maybe it would help if you gave a couple of examples of typical inputs and expected results.