August 2017
Intermediate to advanced
440 pages
10h
English
In strongly typed languages, such as Java or Kotlin, we need to convert values from one type to another explicitly using the cast operator. A typical casting operation is taking an object of one particular type and turning it into another object type that is its supertype (upcasting), subtype (downcasting), or interface. Let's start with a small reminder of casting that can be performed in Java:
Fragment fragment = new ProductFragment();
ProductFragment productFragment = (ProductFragment) fragment;
In the preceding example, there is an instance of ProductFragment that is assigned to a variable storing the Fragment data type. To be able to store this data in the productFragment variable that can store only the ...
Read now
Unlock full access