Java – why is the Boolean value from this array to 2D array true?

Hi, I happened to meet the code sent to me by my friend and had trouble writing the second part of the print statement A [3] is 4, in row 0 and column 2 (B [0] [2]), but why is a [2] 53, proving that B [2] [1] = = 43??? (code print 'true' by the way.)

class Ex1{
     public static void main(String[] args) {

         int a[] = { 1,2,053,4};
         int b[][] = { {1,4},{2,1},{0,43,2}};

         System.out.print(a[3]==b[0][2] );
         System.out.print(" " + (a[2]==b[2][1]));
  }
}

Solution

This happens because 053 is an octal number with a decimal number equal to 43

The 0 prefix represents octal values in Java and other languages (Perl, ruby, C and derivatives, JavaScript, etc.)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>