-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestDataTypes.java
More file actions
65 lines (48 loc) · 1.15 KB
/
TestDataTypes.java
File metadata and controls
65 lines (48 loc) · 1.15 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
This class introduces some basic
data types and operators
*/
public class TestDataTypes{
public static void main(String[] args){
//example for a double from arithmatic operations
double x = 3.0 - 6 * 2;
//example char from octal code
char c = (char) 0132;
//example string
String word = "some Word!";
//another example of string
String anotherWord = "Hi";
anotherWord = "cat";
//another way to instantiate string
String word2 = new String("cat");
//logical/comparison operators
/*
> --> greater than
< --> lesser than
>= --> greater than or equal to
<= --> lesser than or equal to
== --> is equal?
!= --> not equal
&& --> AND
|| --> OR
! --> not
*/
//operators
/*
+ --> addition
- --> substruction
/ --> division
* --> mutlplication
% --> modulus - Remainder
= --> assignment
*/
//example with mod
int r = 10 % 3;
//example conditional expression
boolean flag = x > 5 && r != 0;
//concatenate types to output statements
System.out.println("r " + r);
System.out.println("x " + x);
System.out.println("flag " + flag);
}
}