Solved

java concatenation and special characters

Posted on 2011-03-16
2
403 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 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
login jsp example 24 85
difference between sorce folder and folder in eclipise 3 42
Convert from a json string array to a Java object 3 64
junit as external jar or library 7 38
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

749 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