+ 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);
7 Answers
+ 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]
+ 15
⬜💜💜💜⬜
💜⬜⬜⬜💜
💜💜💜💜💜
💜⬜⬜⬜💜
💜⬜⬜⬜💜
⬜💜💜💜💜
💜⬜⬜⬜⬜
⬜💜💜💜⬜
⬜⬜⬜⬜💜
💜💜💜💜⬜
⬜💜💜💜⬜
⬜⬜💜⬜⬜
⬜⬜💜⬜⬜
⬜⬜💜⬜⬜
⬜💜💜💜⬜
💜⬜⬜⬜💜
💜💜⬜⬜💜
💜⬜💜⬜💜
💜⬜⬜💜💜
💜⬜⬜⬜💜
⬜💜💜💜⬜
💜⬜⬜⬜💜
💜💜💜💜💜
💜⬜⬜⬜💜
💜⬜⬜⬜💜
+ 14
⬜🌹🌹🌹⬜
⬜⬜🌹⬜⬜
⬜⬜🌹⬜⬜
⬜⬜🌹⬜⬜
⬜🌹🌹🌹⬜
🌹🌹🌹🌹⬜
🌹⬜⬜⬜🌹
🌹🌹🌹🌹⬜
🌹⬜⬜⬜⬜
🌹⬜⬜⬜⬜
⬜🌹🌹🌹⬜
🌹⬜⬜⬜🌹
🌹🌹🌹🌹🌹
🌹⬜⬜⬜🌹
🌹⬜⬜⬜🌹
🌹⬜⬜⬜🌹
🌹🌹⬜⬜🌹
🌹⬜🌹⬜🌹
🌹⬜⬜🌹🌹
🌹⬜⬜⬜🌹
⬜🌹🌹🌹⬜
🌹⬜⬜⬜⬜
🌹⬜⬜🌹🌹
🌹⬜⬜⬜🌹
⬜🌹🌹🌹⬜
+ 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);
}
}
+ 5
@Babak is more than a helping hand, and also has artistic sense with emoji :D
#W.O.W#
+ 4
@Babak, very well explained mate, salute! thank you :)
+ 2
@Babak
thank you from all time help..