GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — java-basics/java-programs/Hashcode_Equals.java at master · learning-zone/java-basics Expand file tree/ Copy pathHashcode_Equals.javaMore file actions 44 lines (37 loc) · 1.02 KB / Copy pathHashcode_Equals.javaFile metadata and controls44 lines (37 loc) · 1.02 KB 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. |