File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Displaying others variables in a String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Displaying others variables in a String" Watch "Displaying others variables in a String" New topic
Author

Displaying others variables in a String

Peter Shipway
Ranch Hand

Joined: Mar 25, 2004
Posts: 71
How do you convert a variable to a string? eg if i have

String line;
int n = 0;

how can i make it so that line = "0"?
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140

or

or


Mani
Quaerendo Invenietis
Richard Bradford
Ranch Hand

Joined: Apr 20, 2004
Posts: 48
OR

line = String.valueOf(n);

Which also works with other primatives such as boolean, char etc
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Displaying others variables in a String