FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-basics/java-programs/Hashcode_Equals.java at master · CodeForHunger/java-basics · GitHub
CodeForHunger
/
java-basics
Public
forked from
learning-zone/java-basics
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java-basics
/
java-programs
/
Hashcode_Equals.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (37 loc) · 1.02 KB
Breadcrumbs
java-basics
/
java-programs
/
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
));
}
}
Back
|
FazBrowse Home
|
New Git URL