Sasanka Boxi

Greenhorn
+ Follow
since Jan 04, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sasanka Boxi

Recently we updated the JVM version, is this an issue with JVM
12 years ago
I have updated the code now...could you please verify once...
13 years ago
Hello Experts,

I am constantly getting the bellow error:
Could not rename zip file

Please help.

Here goes my code.

13 years ago
Hello Rob,

We can Override the equals method to compare two similar object(not sure???)

But in my case its the comparision between the object and the String. Can you please place some hints how should I write the code to
override equals() and get the result.


Thanking You.
Sasanka
13 years ago
As you suggested I have tried to override the equals and hashcode method....No Idea how to override the equals method properly....

But Still its not working for me....I have pasted some sample code here

public class Risking
{
String empcode;
String name;
public String getEmpcode() {
return empcode;
}
public void setEmpcode(String empcode) {
this.empcode = empcode;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Risking(String empcode, String name)
{
this.empcode = empcode;
this.name = name;
}
public boolean equals(Object obj)
{
if(obj==null)
return false;
String s= (String)obj;
return s.equals(empcode);
}
public int hashCode()
{
final int PRIME = 31;
int result = 1;
result = PRIME * result + empcode.hashCode();
return result;
}




public static void main(String args[])
{
ArrayList aList = new ArrayList();
Risking r1 = new Risking("117","Rocky");
Risking r2 = new Risking("118","Vicky");
aList.add(r1);
aList.add(r2);
System.out.println(aList.contains("117"));
}
13 years ago
I have a Employee Class with two attributes:- empid and empname.

I have around 1000 Employee Class objects stored in an ArrayList. Now I need to search an Employee Objectin the arraylist based on the Employee ID.

Currently, I am iterating on the arrayList and checking each object's empid property.

Can I write method similar to the contains() of the ArrayList.

Can anyone provide some inputs on this.
13 years ago