Jez Higgins

Freelance software grandad
software created
extended or repaired


Follow me on Twitter
Applications, Libraries, Code
Talks & Presentations

Hire me
Contact

Older posts are available in the archive or through tags.

Feed

Tuesday 20 April 2010 What is the output of this program?

class ArrayTest
{
  static public void main(final String[] args)
  {
    byte[] a = { 1, 2, 3, 4 };
    byte[] b = { 1, 2, 3, 4 };

    System.out.println("a.equals(b) is " + a.equals(b));
    System.out.println("b.equals(a) is " + b.equals(a));
    System.out.println("a.equals(a) is " + a.equals(a));
    System.out.println("====");
    System.out.println("a == b is " + (a==b));
    System.out.println("b == a is " + (b==a));
    System.out.println("a == a is " + (a==a));
  }
}

I've only been working with Java for 13 years, so naturally I got it wrong.


Tagged java


Jez Higgins

Freelance software grandad
software created
extended or repaired

Follow me on Twitter
Applications, Libraries, Code
Talks & Presentations

Hire me
Contact

Older posts are available in the archive or through tags.

Feed