I'm taking an introduction to java class right now, so please don't advice me to something that I have not learned yet. My assignment is that I have to create a class that has two fields. One called length and the other width. I have to make a method that returns the tract area. Similarly, I also have to make a method that indicates whether two objects have the same fields. Here is the code that I have assembled...so far
// create private fields to hold width and length private double width; private double length; //create a constructor that initialized the value public LandTract(double wid, double len) { width=wid; length=len; } // this method will check to see if two object have same data stored in or //not public Boolean objectEqualChecker(LandTract object) { boolean flag; if(length.equals(object.length) && width.equals(object.width)) { flag=true; } }
My problem is encountered when writing that equals method, I get an error sayingif(length.equals(object.length) && width.equals(object.width)). Meanwhile, I do see, to realize that when I change my fields to capital "Double." The problem disappears; however, in my class I have never dealt with a situation where I have to use capital d in double. In fact, I don't even know what's the difference between Double and double. I do know what double is but not the other one...thanks in advance! for taking your time to read thisHTML Code:cannot invoke equals(double) on the primitive type double