> For the complete documentation index, see [llms.txt](https://gyansetu-selenium.gitbook.io/selenium-testing/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gyansetu-selenium.gitbook.io/selenium-testing/type-casting.md).

# Type Casting:

&#x20;Assigning a value of one type to a variable of another type is known as Type Casting. \
In Java, type casting is classified into two types.

![](https://106491783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTW0eWU2biq082hmKEn%2F-LTfi8pQZc7hbFBaYuM6%2F-LTfi_WVDl335qLWgxT0%2Fimage.png?alt=media\&token=7a368a94-44db-4d2a-b953-f8ac3852e289)

&#x20;**Widening or Automatic type conversion**\
&#x20;Automatic Type casting take place when,

* &#x20;the two types are compatible&#x20;
* &#x20;the target type is larger than the source type

![](https://106491783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTW0eWU2biq082hmKEn%2F-LTfi8pQZc7hbFBaYuM6%2F-LTfiwfIWF_Z7C0mmqsa%2Fimage.png?alt=media\&token=c96b0105-763e-430a-811e-4b9d8a187c5b)

#### &#x20;Output:

Int value 100&#x20;

Long value 100&#x20;

Float value 100.0

![](https://106491783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTW0eWU2biq082hmKEn%2F-LTfi8pQZc7hbFBaYuM6%2F-LTfjADIYhYikT3ntOZZ%2Fimage.png?alt=media\&token=8dcf4070-d0f1-48df-b644-0e4a320bb1e6)
