-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConversionDeTipos.java
44 lines (34 loc) · 1.59 KB
/
ConversionDeTipos.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
public class ConversionDeTipos {
public static void main(String[] args) {
String numeroStr = "50";
int numeroInt = Integer.parseInt(numeroStr);
System.out.println("numeroInt = " + numeroInt);
String realStr = "98765.43e-3";
double realDouble = Double.parseDouble(realStr);
System.out.println("realDouble = " + realDouble);
String logicoStr = "TruE";
boolean logicoBoolean = Boolean.parseBoolean(logicoStr);
System.out.println("logicoBoolean = " + logicoBoolean);
int otroNumeroInt = 100;
System.out.println("otroNumeroInt = " + otroNumeroInt);
String otroNumeroStr = Integer.toString(otroNumeroInt);
System.out.println("otroNumeroStr = " + otroNumeroStr);
otroNumeroStr = String.valueOf(otroNumeroInt+10);
System.out.println("otroNumeroStr = " + otroNumeroStr);
double otroRealDouble = 1.23456e2;
String otroRealStr = Double.toString(otroRealDouble);
System.out.println("otroRealStr = " + otroRealStr);
otroRealStr = String.valueOf(1.23456e2f);
System.out.println("otroRealStr = " + otroRealStr);
int i = 22768;
short s = (short) i;
System.out.println("s = " + s);
long l = i;
System.out.println("l = " + l);
System.out.println(Short.MAX_VALUE);
char b = (char) i;
System.out.println("b = " + b);
float f = (float) i;
System.out.println("f = " + f);
}
}