By registering with us, you'll be able to discuss, share and private message with other members of our community.
Sign up now!it isnt implemented?Just to add to that, in case you aren't that familiar with Java:
All objects in Java inherit from class Object, meaning you can use any of the methods listed below with any object.
Object (Java Platform SE 7 )
Yeah test it out.it isnt implemented?
it isnt implemented?
If you dont overrride it you cant use it like arraylist.contains(area)What do you mean? Read my post slowly and carefully.![]()
try itEhhhhhhhhhhhhh ????????????????
try it
Area area1 = new Area.Circular(new Coordinate(0, 0, 0), 2);
Area area2 = new Area.Circular(new Coordinate(0, 0, 0), 2);
System.out.println(area1.equals(area2));
area1 = new Area.Circular(new Coordinate(0, 0, 0), 5);
System.out.println(area1.equals(area2));
try it:
Code:Area area1 = new Area.Circular(new Coordinate(0, 0, 0), 2); Area area2 = new Area.Circular(new Coordinate(0, 0, 0), 2); System.out.println(area1.equals(area2)); area1 = new Area.Circular(new Coordinate(0, 0, 0), 5); System.out.println(area1.equals(area2));
public static final List<Area.Rectangular> nodes = Arrays.asList(
new Area.Rectangular(new Coordinate(4678, 3439, 0), new Coordinate(1678, 3537, 0))
);
println(nodes.contains(new Area(new Coordinate(4678, 3439, 0), new Coordinate(1678, 3537, 0))));
try it:
Code:Area area1 = new Area.Circular(new Coordinate(0, 0, 0), 2); Area area2 = new Area.Circular(new Coordinate(0, 0, 0), 2); System.out.println(area1.equals(area2)); area1 = new Area.Circular(new Coordinate(0, 0, 0), 5); System.out.println(area1.equals(area2));
public boolean equals(Object obj) {
return (this == obj);
}
I meant this:
Code:public static final List<Area.Rectangular> nodes = Arrays.asList( new Area.Rectangular(new Coordinate(4678, 3439, 0), new Coordinate(1678, 3537, 0)) ); println(nodes.contains(new Area(new Coordinate(4678, 3439, 0), new Coordinate(1678, 3537, 0))));
both print false
public static void main(String[] args) {
Integer i1 = 2;
Integer i2 = 2;
List<Integer> ints = Arrays.asList(new Integer(2)); //Unnecessary boxing but for example's sake
List<Integer> ints2 = Arrays.asList(i2);
System.out.println(i1.equals(i2));
System.out.println(i1 == i2); //bad, don't do
System.out.println(Objects.equals(i1, i2));
System.out.println(ints.contains(i1));
System.out.println(ints.contains(i2));
System.out.println(ints2.contains(i1));
System.out.println(ints.contains(i2));
System.out.println(ints.contains(2));
System.out.println(ints2.contains(2));
}
true
true
true
true
true
true
true
true
true
Those are true because class Integer overrides the equals method:Probably, neither are valid coordinates (goof example). If you were to do it with Integers/anything else, you would get the point.
What is it you're trying to accomplish? Whatever you're doing currently, it's probably wrong.
Code:public static void main(String[] args) { Integer i1 = 2; Integer i2 = 2; List<Integer> ints = Arrays.asList(new Integer(2)); //Unnecessary boxing but for example's sake List<Integer> ints2 = Arrays.asList(i2); System.out.println(i1.equals(i2)); System.out.println(i1 == i2); //bad, don't do System.out.println(Objects.equals(i1, i2)); System.out.println(ints.contains(i1)); System.out.println(ints.contains(i2)); System.out.println(ints2.contains(i1)); System.out.println(ints.contains(i2)); System.out.println(ints.contains(2)); System.out.println(ints2.contains(2)); }
Code:true true true true true true true true true
public boolean equals(Object obj) {
if (obj instanceof Integer) {
return value == ((Integer)obj).intValue();
}
return false;
}
@Party ur getting rekt by this support
@Party ur getting rekt by this support
Ofc there is a work around, but its kinda annoying.wouldn't surprise me - not to be making excuses but I've driven for 12 hours today so my brain is melting away at the edges
let me sleep and I'll come back and tell you either A. why you're wrong or B. how you could do it
We use essential cookies to make this site work, and optional cookies to enhance your experience.