sap training in delhi
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   skybrijesh
Posted On:   Friday, September 27, 2013 04:14 AM

I want to save the objects of class Position in a HashSet object. the Position class is as the following: class Position { public Position(){ .... } public boolean equals(Object obj){ if (!(obj instanceof Position)) return false; Position tmp = (Position) obj; if ( x == tmp.px && y == tmp.py) return true; else return false; } private int x, y; } and when I ran the following code: Set set = new HashSet(); set.add(new Position(1, 1)); if (set.contains(Position(1, 1)) System.out.println("True"); else System.out.println("False"   More>>

I want to save the objects of class Position in a HashSet object. the Position class is as the following:

				
class Position {
public Position(){
....
}

public boolean equals(Object obj){
if (!(obj instanceof Position))
return false;
Position tmp = (Position) obj;
if ( x == tmp.px && y == tmp.py)
return true;
else
return false;
}
private int x, y;
}


and when I ran the following code:

			

Set set = new HashSet();
set.add(new Position(1, 1));
if (set.contains(Position(1, 1))
System.out.println("True");
else
System.out.println("False");


the output is False!

Can anyone tell me why? How can I make it correct?

Normal 0 false false false EN-US X-NONE X-NONE <![endif]-->

Sky InfoTech  is  a  premier  company  engaged  in   IT Services, Corporate   Industrial, Individual   and ERP- SAP Training with software development   Consultancy, Recruitment & Man power Outsourcing.

We Provide Training in given below :

SAP/ERP, ORACLE, DOT NET , PHP Training, JAVA, SQT, Cloud   Computing, Embedded System, MATLAB, Linux, Unix, Android, IPHONE, Black berry, Data Warehousing, Cognos, Informatica, DataStage, ETL, Industrial, Corporate Training, SAS Analytic Training.

We have a independent Placement Cell devoted to cater to the needs of organizations looking for suitable  candidates  for  their  requirements. A  full fledge HR team having experience in  placing  candidates  in different industries runs this  Dept. 

Thanks & Regards ,

Sky InfoTech 

Corporate Office:

A-50,Sec-64,Noida(U.P)

Contact---------
Noida - 0120 4242224, 9717292598/9717292599

Delhi –9717292601/9717292602

Gurgaon – 9810866624/9810866642

Website     -    http://www.skyinfotech.in

 

 

<![endif]-->    <<Less
About | Sitemap | Contact