Posted by: Sourav | October 27, 2016

Convert to String to other Data Types in Java,Java Teacher Sourav,Kolkata 09748184075


class a{
public static void main(String args[])
{

byte b=Byte.valueOf(args[0]);
System.out.println(“b is “+ b);
short s =Short.valueOf(args[0]);
System.out.println(“b is “+ s);
int i=Integer.valueOf(args[0]);
System.out.println(“i=” +i);
long l=Long.valueOf(args[0]);
System.out.println(“l =” +l);
float f=Float.valueOf(args[0]);
System.out.println(“f =” +f);

Double d=Double.valueOf(args[0]);
System.out.println(“d =” +d);
b=Byte.parseByte(args[0]);
System.out.println(“b is “+ b);
s=Short.parseShort(args[0]);
System.out.println(“s is “+ s);
i=Integer.parseInt(args[0]);
System.out.println(“i is “+ i);
l=Long.parseLong(args[0]);
System.out.println(“l is “+ l);
f=Float.parseFloat(args[0]);
System.out.println(“f is “+ f);

d=Double.parseDouble(args[0]);
System.out.println(“d is “+ d);

 
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: