What is the best/better approach to writing below code?
I need to send a welcome message to my user like,
Hello FirstName, thanks for choosing example.com. Your registered email is firstname.lastname@example.com
The current implementation that I have is,
public static final String WELCOME_MSG = "Hello %s, thanks for choosing example.com. Your registered email is %s";
System.out.println(String.format(WELCOME_MSG, firstName, email));
Now, what could be a better approach in terms of memory and computation?
One approach came to my mind is, break the constant in multiple parts like
public static final String HELLO_MSG = "Hello ";
public static final String THANKS_MSG = ", thanks for choosing example.com. Your registered email is ";
System.out.println(HELLO_MSG + firstName + THANKS_MSG + email);
But, if I think about multiple cases like this, is it good?
Thanks in Advance!