typecasting Flashcards
1
Q
from String to int
A
int num= Integer.parseInt(str);
2
Q
from string to double
A
double num= Double.parseDouble(str);
3
Q
from double to int
A
int intNum= (int) dblNum;
4
Q
from int to double
A
double dblNum= intNum;
5
Q
from int to char
A
char ch=(char) intNum;
6
Q
from double to String
A
String str= “ “ + dblNum;
7
Q
from char to String
A
String str= “ “ + ch;
8
Q
String to char
A
char ch=str.charAt(position);