-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTiposPrimitivos.java
More file actions
40 lines (29 loc) · 952 Bytes
/
TiposPrimitivos.java
File metadata and controls
40 lines (29 loc) · 952 Bytes
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
package Fundamentos;
import org.omg.Messaging.SyncScopeHelper;
public class TiposPrimitivos {
public static void main(String[] args) {
//Tipo primitivo booleano
boolean bo1 = false;
boolean bo2 = true;
System.out.printf("%b %b\n", bo1, bo2);
//Tipo primitivo caracter
char c1 = 'a';
char c2 = '!';
char c3 = '\u0050';
System.out.printf("%c %c %c\n", c1, c2, c3);
//Tipo primitivos inteiros
byte b = -127;
short s = 32767;
int i = 2_147_483_647;
long l = 9_223_372_036_854_775_807L;
System.out.printf("%d, %d, %d %d\n", b, s, i, l );
System.out.println(Integer.toBinaryString(b));
System.out.println(Integer.toBinaryString(s));
System.out.println(Integer.toBinaryString(i));
System.out.println(Long.toBinaryString(l));
//Tipos primitivos reais (ponto flutuante)
float f = 3.1416F;
double d = 2.45;
System.out.printf("%.2f %f", f, d);
}
}