Added a section called "Casting". Details on how data types can be stored in other data types. (#23881)

* Added a section called "Casting"

* Reordered section, fixed typo
This commit is contained in:
Nathan-Abegaz
2018-12-01 18:55:44 -08:00
committed by Manish Giri
parent 7f00161e60
commit 61b6f1e19e

View File

@ -197,3 +197,19 @@ Output:
```
10198442
```
### Casting
It is also important to note that it is possible to store different data types into one another. However, you would have to let the compiler know that you have acknowledge the possible loss of data by casting the variable.
For example:
```java
double d = 1.23
int i = (int)d;
System.out.println(i);
```
Output:
```
1
```