// The "StringReplacement" class.
import java.awt.*;
import hsa.Console;

public class StringReplacement
{
    static Console c;           // The output console

    public static void main (String[] args)
    {
        c = new Console ();

        String word;
        String word2;
        String sentences;
        int i;

        c.print ("Enter the word to be replaced: ");
        word = c.readLine ();
        c.print ("Enter the word to replace it; ");
        word2 = c.readLine();
        c.print ("Enter the sentence: ");
        sentences = c.readLine ();

        String[] arraystr = sentences.split (" ");

        for (i = 0 ; i < arraystr.length ; i++)
        {
            if (arraystr [i].equals (word))     
            c.print (word2);         
            c.print (arraystr [i] + " ");
            
        }

    } // main method
} // StringReplacement class

My problem is I need to remove the word at the arraystr and replace it with word2 without using substring(). Anyone can help?

Nevermind I was able to fixed. :)