JAVA, Programmimg Languages

Type Casting in Java

While programming, sometimes there is situation encounter, where we have to store a value of one type into a variable of another type. In such situations, we have to cast the value to be stores by processing it. The syntax is:

 type variable 1 = (type) variable2;

The process of converting one data type to another is called casting.

Casting is often necessary when a method returns a type different than the one we require.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s