GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — java-basics/java-programs/Hashcode_Equals.java at master · learning-zone/java-basics

Expand file tree

/

Hashcode_Equals.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
44 lines (37 loc) · 1.02 KB
/

Hashcode_Equals.java

Copy path

File metadata and controls

44 lines (37 loc) · 1.02 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package misc;
/**
* Note:-
* 1. equals(Object obj): a method provided by java.lang.Object that
* indicates whether some other object passed as an argument is "equal to" the
* current instance.
* 2. hashcode(): a method provided by java.lang.Object that
* returns an integer representation of the object memory address.
*
*/
public class Hashcode_Equals {
private int id;
private String name;
public Hashcode_Equals(int id, String name) {
this.name = name;
this.id = id;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static void main(String[] args) {
Hashcode_Equals obj1 = new Hashcode_Equals(1, "Alex");
Hashcode_Equals obj2 = new Hashcode_Equals(1, "Alex");
System.out.println("Alex1 hasCode(): " + obj1.hashCode());
System.out.println("Alex2 hasCode(): " + obj2.hashCode());
System.out.println("Checking equality: " + obj1.equals(obj2));
}
}
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.