Friday, 29 January 2016

Java Tutorial : Generate hashCode and equals method using eclipse


Click here to watch in Youtube :
https://www.youtube.com/watch?v=mohRInH9h-U&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Generate hashCode and equals method using eclipse
Java Tutorial : Generate hashCode and equals method using eclipse
Java Tutorial : Generate hashCode and equals method using eclipse
Java Tutorial : Generate hashCode and equals method using eclipse
Employee.java
public class Employee
{
    private String name;
    private int age;
    private int salary;

    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + age;
        result = prime * result
                + ((name == null) ? 0 : name.hashCode());
        result = prime * result + salary;
        return result;
    }

    @Override
    public boolean equals(Object obj)
    {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Employee other = (Employee) obj;
        if (age != other.age)
            return false;
        if (name == null)
        {
            if (other.name != null)
                return false;
        }
        else if (!name.equals(other.name))
            return false;
        if (salary != other.salary)
            return false;
        return true;
    }

}
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/GenerationDemo_Eclipse_hashcode_equals_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/GenerationDemo_Eclipse_hashcode_equals_App/GenerationDemo

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/d8bcbd739d9d2ceaeec7ee56b1959925c6ec69d4/BasicJava/GenerationDemo_Eclipse_hashcode_equals_App/GenerationDemo/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment