Changing the first occurrence of a text in a sentence
This, and your past few questions you have asked, have been progressively getting better.

In particular, the naming of methods and variables in this question is much better. You are suffering from 'Hungarian Notation' in the constant name. There is no need to call it STRING_TO_BE_CHANGED because we know it is a String. A simpler name TO_CHANGE would be fine.

In order to take your programming mindset to 'the next level', you have to start to abstract the functions from the particular use case. How do you write your program to solve a general problem, and apply it to a specific use case?

In this program of yours, the guts of the function newLine() can only solve one problem, changing hate to love, in a single phrase.

What I would like to see is a more general use case. In this problem, you have three Strings:


I hate you
hate
love


The objective is to search the first string for the second, and to replace it with the third.

A general function would look like:

public static String replaceWordInText(String phrase, String search, String replacement) {...}


That function embodies the logic you are trying to do, and it can replace any search with any replacement in any text.

How would this be used to solve the problem you have in the book?

public class Question5 {

    private static final String TO_SEARCH = "I hate you";
    private static final String TO_CHANGE = "hate";
    private static final String REPLACE_WITH = "love";

    public static void main(String[] args) {

        System.out.println("The line to be changed is:");
        System.out.println(STRING_TO_BE_SEARCHED);
        System.out.println("I have rephrased that line to read:");
        String result = replaceWordInText(TO_SEARCH, TO_CHANGE, REPLACE_WITH);
        System.out.println(result);
    }

    public static String replaceWordInText(String phrase, String search, String replacement) {
        ....
    }

}


Now, we have a general function applied to a specific use-case. How would the general function be implemented? Well, you have already solved that using the replaceFirst method

    public static String replaceWordInText(String phrase, String search, String replacement) {
        return phrase.replaceFirst(search, replacement);
    }