Witshaper is the Professional (Computing Skills, English Learning and Soft Skills) Skill Development Training Center. We provide Professional IT Courses and Soft Skill Training in Dehradun to Students, Employees and organization. Who wish to pursue a career in IT Technology. Witshaper is led by a motivated team of IT experts and Soft Skill Professionals. We provide high quality trainings. Our Emphasis is on giving the practical knowledge to the students, so that they will get to know in depth and never forget what they opt, we provide to the students real learning environment. Witshaper prepares students and professionals to be the part of this growing industry. Be a part of Witshaper and get your dreams successful

Monday 18 May 2015

java program to show conversion of string to float ,int and vice versa


1) integer
public class Convert{
public static void main(String[] args){
System.out.println("****Conversion of Int to Integer****");
int i=10;
Integer z= Integer.valueOf(i);
System.out.println("Value of z="+i);
System.out.println("****Conversion of Integer to String****");
String s;
s= Integer.toBinaryString(12);
System.out.println("Value of s is "+s);
System.out.println("****Conversion of Integer to Int****");
Integer y= new Integer(12);
int x= y.intValue();
System.out.println("Value of x"+x);
System.out.println("****Conversion of String to Int****");
double a= Double.parseDouble("123.123");
int k=(int)a;
System.out.println("Value of k="+k);
System.out.println("****Conversion of String to Integer****");
short v= Short.parseShort("10011",2);
Integer b= new Integer(v);
System.out.println("Value of b="+b);
System.out.println("****Conversion of Int to String****");
int e=10;
Integer g= new Integer(e);
String f= Integer.toString(213);
System.out.println("Value of f is "+f);
}
}


2)float


public class Conversion{
public static void main(String[] args){
System.out.println("****Conversion of Float to float****");
float f= new Float("123.23");
System.out.println("Value of f="+f);
System.out.println("****Conversion of Float to String****");
Float g= new Float(123.123);
String y= String.valueOf(g);
System.out.println("Value of y is "+y);
System.out.println("****Conversion of String to Float****");
Float k= Float.valueOf("170.78");
System.out.println("Value of k="+k);
System.out.println("****Conversion of String to float****");
float z= Float.parseFloat("71.11");
System.out.println("Value of z="+z);
System.out.println("****Conversion of float to Float****");
float a=122.24f;
Float x= Float.valueOf(a);
System.out.println("Value of x"+x);
System.out.println("****Conversion of float to String****");
float h=18.45f;
String s= String.valueOf(h);
System.out.println("Value of s is "+s);
}

}

No comments:

Post a Comment