answersLogoWhite

0

Type casting means to explicitly convert one type to another.

For example, the following lines:

double x = 5.0;
int y = x;

will produce an error message, because of a possible loss of precision (any decimals will get lost when converting to int). The following will work however:

double x = 5.0;
int y = (int) x;

The programmer is forcing the Java compiler to accept the conversion; saying, in effect: "Please do this anyway, I know what I am doing".

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

How do you change a float into a double using java?

with help of type casting it is possible


Why do use typecasting in java?

Type casting is used to convert from one datatype to the other


Can you define variables in interface in java?

yes we can define a variable in an interface in java.


Why is there type casting in java?

Type casting exists to allow the use of base class or base interface reference but yet if you know that the object in hand is aspecific derived class, you can typecast and access methods available only in the derived class.


Define set in java?

A Java set is a collection of things that do not contain duplicate elements. Duplicates are prohibited from Java sets.


What is the hierarchy of the java program?

define the data types


What is function in java terminology?

In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.


Name two high level languages and define them?

Java C++


How do you uss static in java?

It is uss to define class and method of pogrom's.


Is java virtual machine dangerous?

JVM is a critical component in almost all Java platforms. I would hardly define it as "dangerous".


What type of government in java?

Java has a Communist government.


How do you define one-to-n mapping in java?

well first please go and play Minecraft on java and then a crepper will tell you👍👍