Java Data Type Casting
Integer
int a=10;
Int to String -- String b=a+””; or b=a.toString();
Int to char – Char b=(char)a;
int to long -- long b=Long.valueOf(a);
int to double -- double b=a;
int to float -- float b=a;
Integer
String
String a="harsh";
int index=1
String to char -- char b=a.charAt(index);
String to int -- int b=Integer.parseInt("10");
String to long -- long b=Integer.parseInt("10");
String to double-- double b=Float.parseFloat("10.00");
String to float-- float b=Float.parseFloat("10.00");
No comments:
Post a Comment