Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

incompatible types: possible lossy conversion from int to char in java.how to solve it.

0 votes
asked Jul 20, 2019 by pradeep puri goswami

2 Answers

0 votes
answered Jul 21, 2019 by Arabinda Acharya
This problem occurs as int is 4 byte and char is 2 byte. So you have to type cast explicitly to avoid error.

e.g:==  int a=10;

            char c=(char)a;
+1 vote
answered Jul 23, 2019 by Monkey
Lossy conversion means you are losing some information.

if int is 4 bytes and char is 2 bytes how can you stored 4 byte information in 2 byte.

So if you still want to convert you can explicitly convert by type conversion. But remember you are still losing some information :)
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...