Add bytes with type casting, Java

后端 未结 7 1381
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 23:58

I am trying to add two values in a byte array. This is my code:

byte[] ars = {3,6,9,2,4};
ars[0] = (byte)ars[0] + (byte)ars[4];
System.out.println( ars[0] );         


        
相关标签:
7条回答
  • 2020-12-02 00:57
    ars[0] = (byte)(ars[0] + ars[4]);
    
    0 讨论(0)
提交回复
热议问题