Practice

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page

Will pointA.equals(pointB) return the same true/false value as pointB.equals(pointA) ?

Answer:

Yes.

Practice

Perhaps you would like to practice? Assume that each row is independent of the others.

code sectionpointA == pointB pointA.equals( pointB )
Point pointA = new Point( 0, 0 );
Point pointB = new Point( 0, 0 );
Point pointA = new Point( 21, 17 );
Point pointB = pointA;
Point pointA = new Point( 21, 17 );
Point pointB = new Point( 7*3, 20-3 );

Point pointA = new Point( 21, 17 );
Point pointB = new Point( pointA );
Point pointA = new Point( 21, 17 );
Point pointB = new Point( 21, 17 );
pointA.move( 8, 12 );

QUESTION 23:

Do you imagine that professional programmers ever get == and equals confused?