Type Casting in Java: Type Conversion in Java


Convert Sting to Int:

String str = "1234";
int foo = Integer.praseInt(str);

Convert Char to Int:

char a = '3';
int foo = (int) a-48;

String to Char Array:

String str = "1234";
char [] charary = str.toCharArray();

Covert Int to String:

int w=1234;
String se=Integer.toString(w);

Convert Double to int:

double x=22.4;
int a= (int)x;

Convert long to int:

long a =10;
int  s = (int) a;

Convert String to BigInteger:


String b="1234422";

BigInteger a=new BigInteger(b); 

No comments

Powered by Blogger.