018-004-004

Object Comparison: The equals Method

Easy

Problem Description

Object Comparison: The equals Method

Learning Objective: Understand how to override the equals method to compare object contents

Overview

Create a Point class and override the equals method to determine if two Point objects have the same coordinates.

Specifications

  • Point class: x, y fields
  • Override equals method to return true if coordinates are the same

Input

Coordinates of two points (x1 y1 x2 y2) are provided

Output Format

Point1: (3, 5)
Point2: (3, 5)
Equal: true

Test Cases

※ Output examples follow programming industry standards

Input:
3 5 3 5
Expected Output:
Point1: (3, 5)
Point2: (3, 5)
Equal: true
Input:
1 2 3 4
Expected Output:
Point1: (1, 2)
Point2: (3, 4)
Equal: false
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 9 free executions remaining