CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 Converting datatype in Java

Print topic Send  topic

Author Message
elizas

Posts: 2
Posted: 02/26/2010, 3:34 AM

Below are some examples of conversion from one data type to another in java.

double to String :
String str = Double.toString(i);

long to String :
String str = Long.toString(l);

float to String :
String str = Float.tString(f);

String to integer : str = "25";
int i = Integer.valueOf(str).intValue();
or
int i = Integer.parseInt(str);

String to double :
Double d = Double.valueOf(str).doubleValue();

String to long:
long l = Long.valueOf(str).longValue();
or
Long L = Long.parseLong(str);

String to float :
Float f = Float.valueOf(str).floatValue();

decimal to binary : int i = 42;
String bin = Integer.toBinaryString(i);

Hope u this tip was useful.

Eliza

http://www.mindfiresolutions.com/Converting-datatype-in-Java-46.php
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.