-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashcode.java
More file actions
31 lines (25 loc) · 824 Bytes
/
Copy pathhashcode.java
File metadata and controls
31 lines (25 loc) · 824 Bytes
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
package HashCode;
public class hashcode {
private int sid;//Instance Variable
//constructor
hashcode (int sid){//The constructor takes an integer parameter sid
this.sid=sid;//and assigns it to the instance variable sid
}//keyword this is used within an instance method or constructor to refer to the current object. It differentiates between instance variables and parameters or other variables with the same name
@Override
public int hashCode() {
return sid;
}
@Override
public String toString() {
return "Hashcode{" + "sid=" + sid + '}';
}
public static void main(String[] args) {
hashcode t= new hashcode(150);
System.out.println(t);
System.out.println(t);
System.out.println(t);
System.out.println(t);
hashcode t1=new hashcode(20);
System.out.println(t1);
}
}