How to specify a specific word and open it to the next line

Asked 2 years ago, Updated 2 years ago, 17 views

If you specify a specific word for the source

I'm going to read the sentence after that word

What should I do?

For example,

I want to go home. If there's a sentence that says, "Do you want to go home?" If I write a specific word in the source and execute it,

I want to go home.

Do you want to go home?

To make it look like this.

What should I do?

java

2022-09-21 16:51

1 Answers

Use the replace method in string. Example)

class CodeRunner{
    public static void main(String[] args){
        String1 = "I want to go home. Do you want to go home? I want to go to the company. Do you want to go to the company?";
        String 2 = s1.replace ("Da"), "Da".\n");
        System.out.println(s2);
    }
}


2022-09-21 16:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.