Results 1 to 7 of 7
- 09-01-2008, 08:04 AM #1
- 09-01-2008, 08:09 AM #2
Change this as follows.
byte c= (byte) (a + b);
Check the following code segment.
byte a=10; byte b=5; int c=a+b; System.out.println(c);
- 09-01-2008, 08:15 AM #3
thank you sir
- 09-01-2008, 08:16 AM #4
- 09-01-2008, 08:49 AM #5
byte and short variables are automatically convert into int, if you are not specifically define. See the example below.
short a = 12; short b = 23; short c = a + b;
Same thing is happen for byte variables as well, I'll explain in the previous code.
On the other hand, float values also assign to double.
If you want to stuck with the same type, need explicit cast.
- 09-01-2008, 09:14 AM #6
- 09-01-2008, 09:23 AM #7
- By CrazyShells Slam in forum New To JavaReplies: 0Last Post: 05-15-2008, 02:56 PM
- By rgale in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 05-12-2008, 04:28 PM
- By SKaur in forum New To JavaReplies: 7Last Post: 01-12-2008, 09:02 PM