Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

java concatenation and special characters

Posted on 2011-03-16
2
Medium Priority
?
409 Views
Last Modified: 2012-05-11
a,b,c are variables.
And I want to concatenate them. So I have two related questions:

1- If I do the following, is it gonna process "\n" as a new line character or literally \n? If literally \n, then how can I make it processed as new line character?

2- So I have variable a in my hand. And I want to add b and c as a prefix to a not a suffix. I mean in the beginning of what is in a now. Is this gonna work? If not how can I make it?

a = b + "\n" + c + a;

Open in new window

0
Comment
Question by:Tolgar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 35152114
That newline will be interpreted as an escape sequence so you'll actually get a newline in the String. Print it out and you'll see
0
 
LVL 92

Expert Comment

by:objects
ID: 35152137
1. It will be treated as a new line char. Generally better to use System.getProperty("line.separator") as it will be line seperator for the platform you are running on
2. you can change the order of concatentation however you like
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question