This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes return? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "return? " Watch "return? " New topic


Rayt Leeop

Joined: Jun 09, 2011
Posts: 23
The code:

public String toString() {
return "X=" + x + " " + "Y=" + y;

the result is "x=.., y=.."

How can I make xw in two lines:
Christopher Nortje

Joined: Jul 09, 2010
Posts: 16
Just add a newline (line feed) character instead of the space " " use "\n"
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 37936
Better not to use \n unless you specificially require \n. You actually want line end. It would be better to use the %n tag:
I agree. Here's the link:
subject: return?
Similar Threads
Operator precedence
Rounding up function
Java Increment Operator pre/post fix
question on iteration