Ask your own question, for FREE!
Computer Science 19 Online
OpenStudy (alprincenofl):

Write Java program that initialize a string with "Hello, Java!" and then change it to “Hello, World!”.

OpenStudy (woodrow73):

Hey.

OpenStudy (anonymous):

I would suggest checking out the String class. In particular check out the substring method that String Class provides. That should pretty much answer your question on exception to the actual syntax which you should be able to do yourself.

OpenStudy (woodrow73):

Ya as pipsy said, you can use the String class's substring method- or you can use the String classes replace method- or even the StringBuilder class's delete & append methods or the StringBuilder's replace method. or the StringBuilder's setCharAt in a for loop, then append the last d (because world is 1 character longer than java). Or you can go the old fashion route, and just set the string variable equal to "Hello, World"

OpenStudy (alprincenofl):

public class WriteHelloWorld { public static void main(String[] args) { String hello="Hello, Java!"; System.out.println(hello); hello="Hello, World!"; } }

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!