+ 3

How can I assign a Byte value type to an int variable in Java?

I do like this but I get error Byte n1=120; Byte n2=120; short n3 =20000; short total=(short)(n1+n2+n3);

8th Oct 2017, 6:20 PM
Super Programmer
Super Programmer - avatar
7 ответов
+ 16
Dear Asina This code contains some information for you. BTW, your way of conversion between types has no issue in this particular case. [https://code.sololearn.com/czszbMDuPjFc]
9th Oct 2017, 7:31 AM
Babak
Babak - avatar
+ 15
⬜💜💜💜⬜ 💜⬜⬜⬜💜 💜💜💜💜💜 💜⬜⬜⬜💜 💜⬜⬜⬜💜 ⬜💜💜💜💜 💜⬜⬜⬜⬜ ⬜💜💜💜⬜ ⬜⬜⬜⬜💜 💜💜💜💜⬜ ⬜💜💜💜⬜ ⬜⬜💜⬜⬜ ⬜⬜💜⬜⬜ ⬜⬜💜⬜⬜ ⬜💜💜💜⬜ 💜⬜⬜⬜💜 💜💜⬜⬜💜 💜⬜💜⬜💜 💜⬜⬜💜💜 💜⬜⬜⬜💜 ⬜💜💜💜⬜ 💜⬜⬜⬜💜 💜💜💜💜💜 💜⬜⬜⬜💜 💜⬜⬜⬜💜
9th Oct 2017, 8:25 AM
Babak
Babak - avatar
+ 14
⬜🌹🌹🌹⬜ ⬜⬜🌹⬜⬜ ⬜⬜🌹⬜⬜ ⬜⬜🌹⬜⬜ ⬜🌹🌹🌹⬜ 🌹🌹🌹🌹⬜ 🌹⬜⬜⬜🌹 🌹🌹🌹🌹⬜ 🌹⬜⬜⬜⬜ 🌹⬜⬜⬜⬜ ⬜🌹🌹🌹⬜ 🌹⬜⬜⬜🌹 🌹🌹🌹🌹🌹 🌹⬜⬜⬜🌹 🌹⬜⬜⬜🌹 🌹⬜⬜⬜🌹 🌹🌹⬜⬜🌹 🌹⬜🌹⬜🌹 🌹⬜⬜🌹🌹 🌹⬜⬜⬜🌹 ⬜🌹🌹🌹⬜ 🌹⬜⬜⬜⬜ 🌹⬜⬜🌹🌹 🌹⬜⬜⬜🌹 ⬜🌹🌹🌹⬜
9th Oct 2017, 8:23 AM
Babak
Babak - avatar
+ 5
What error did you get? I run your code just fine in Code Playground, just added simple print statement. public class Program { public static void main(String[] args) { byte n1=120; byte n2=120; short n3 =20000; short total=(short)(n1+n2+n3); System.out.println(total); } }
8th Oct 2017, 7:29 PM
Ipang
+ 5
@Babak is more than a helping hand, and also has artistic sense with emoji :D #W.O.W#
9th Oct 2017, 8:31 AM
Ipang
+ 4
@Babak, very well explained mate, salute! thank you :)
9th Oct 2017, 8:20 AM
Ipang
+ 2
@Babak thank you from all time help..
9th Oct 2017, 8:23 AM
Super Programmer
Super Programmer - avatar