Does anyone know how to print the "in an output line?
Like I want my output link to be: name = "Purple"
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Does anyone know how to print the "in an output line?
Like I want my output link to be: name = "Purple"
Use an escape character. Like this:"\"Purple\""
Recommended reading: Characters (The Java™ Tutorials > Learning the Java Language > Numbers and Strings)
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Thanks for that.
Then the next question, how do I print a value behind it.
Like:
String Chr = Y; "\"Purple" + Chr"\"
"\"Purple" + Chr"\" --> doesn't work.
I would like as output "PurpleY"
Last edited by Purple01; November 27th, 2012 at 07:49 AM. Reason: Editiong capital letters
I will mind the capital letter next time yes.
Chr and chr are the same, I will adjust that in my post.
You have to remember that "\"" is a String, so you do String concatenation exactly like you do with any other String. For example, consider this:
String chr = "Y"; "Purple" + chr + "." //PurpleY.
Also consider using a StringBuilder instead of String concatenation.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Purple01 (November 27th, 2012)
Thanks for letting me know that.
I also noticed that by splitting .. you also need those \\ things before it.
I'm not sure exactly what you mean, but yeah, anytime you have a quotation mark inside a String, you need to escape it. Doesn't matter if the String is split up into multiple String primitives or not.
Unless you're talking about the String.split() function, which takes a regular expression String, so you have to escape the escape sequence...
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!