answersLogoWhite

0

Type casting means explicitly converting one data type to another. For example, the following won't be allowed:

int a;
long b;
b = 5;
a = b;

In the last line, the compiler will complain, due to a possible data loss - long has a larger range. But if you believe that the conversion won't cause a problem in your program, you can override the error message with an explicit conversion (or typecast):

...
a = (int) b;

Type casting means explicitly converting one data type to another. For example, the following won't be allowed:

int a;
long b;
b = 5;
a = b;

In the last line, the compiler will complain, due to a possible data loss - long has a larger range. But if you believe that the conversion won't cause a problem in your program, you can override the error message with an explicit conversion (or typecast):

...
a = (int) b;

Type casting means explicitly converting one data type to another. For example, the following won't be allowed:

int a;
long b;
b = 5;
a = b;

In the last line, the compiler will complain, due to a possible data loss - long has a larger range. But if you believe that the conversion won't cause a problem in your program, you can override the error message with an explicit conversion (or typecast):

...
a = (int) b;

Type casting means explicitly converting one data type to another. For example, the following won't be allowed:

int a;
long b;
b = 5;
a = b;

In the last line, the compiler will complain, due to a possible data loss - long has a larger range. But if you believe that the conversion won't cause a problem in your program, you can override the error message with an explicit conversion (or typecast):

...
a = (int) b;

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake
DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
More answers

Type casting means explicitly converting one data type to another. For example, the following won't be allowed:

int a;
long b;
b = 5;
a = b;

In the last line, the compiler will complain, due to a possible data loss - long has a larger range. But if you believe that the conversion won't cause a problem in your program, you can override the error message with an explicit conversion (or typecast):

...
a = (int) b;

User Avatar

Wiki User

15y ago
User Avatar

Add your answer:

Earn +20 pts
Q: Explain about type casting in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp