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.

Comments

Popular posts from this blog

Connect to Microsoft SQL Server via JDBC

Connect to MySQL database via JDBC

Why online education becomes popular?