Win a copy of Programmers Guide to Apache Thrift this week in the Open Source forum!

Daniel Kavanaugh

+ Follow
since Aug 12, 2012
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Daniel Kavanaugh

Thanks for posting, guys. Everything compiles now, but unfortunately, I'm still a little confused about some of the stuff stated in your posts. I really apologize.

I've been attempting to correct this program so that it can be displayed in a gui (although all I need it to do is display the arrays in something that isn't the command prompt). Should I just continue, or are there things I absolutely need to fix before displaying the data? Right now, it displays all necessary data, except the result of the findWholeInventory method.


I did not change Camera.

6 years ago
Also, would it be possible for me to display all the elements in these arrays within a GUI?
6 years ago
So Should it read cameras.findWholeInventory(cameras[3]); ?

6 years ago error: cannot find symbol
symbol: method findWholeInventory(Camera)
location: class Inventory
6 years ago
That would certainly help. There's a lot of unneeded code in DigitalCamera, but I don't like changing things until I get everything working.

6 years ago
Hi everyone,

I'm getting an error that reads 56: error: cannot find symbol on line findWholeInventory(cameras[3]); symbol: method findWholeInventory(Camera) location: class Inventory

I'm confused by this because I define this method in the class Camera:

and I have defined Camera in the Inventory class:

DigitalCamera is a subclass that extends Camera, could that be a problem? Everything compiles fine except the inventory class with the aforementioned error. Do I just need to change the syntax on the array that it reads from?
6 years ago
Didn't I define all the needed methods?
6 years ago
@Prasad prap, I apologize for still being unable to do this, but I am having further errors. Should I be approaching this a different way, or do you think I can make this eventually work? Thanks so much for your help. error: Camera is not abstract and does not override abstract method compareTo(Camera) in comparable
public class Camera implements Comparable<Camera> error: compareTo(Camera) in Camera cannot implement compareTo(T) in comparable
public String compareTo(Camera compareCamera)

return type String is not compatible with int
where T is a type-variable:
T extends Object declared in interface Comparable error: non-static variable productName cannot be referenced from a static context
String productName1 = camera1.getProductName(productName); error: non-static variable productName cannot be referenced from a static context
String productName2.getProductName(productName);

6 years ago

Prasad prap wrote:Have a close look at this example:
Comparator example

Let me know if you have trouble fitting that in your example.

Thanks for the link, it really helped. My code is almost exactly the same as that, but I'm still getting 3 identifier expected errors in the public class Camera implements Comparable<Camera> line. I've attached the file. I'm probably missing something very obvious, but it eludes me.

(Sorry that it's above the character count)
6 years ago
Thanks for the replies.

Stevens Miller wrote:Daniel, I believe your Camera class must implement the Comparable interface. Look at the docs on the Arrays method you are using.

I've read this on another site as well, but I'm having trouble in actually writing the code needed to do this.
I looked at the docs you provided and created a public static void sort(Object[] a) method in my Camera class, but wasn't sure what to fill it with. I think I'm missing what exactly this really means.

@Henry How might I create a comparator?

@Prasad I'm having difficulty understanding how that question works, as I don't see where valueOfFood comes from

@Winston sorry for being sloppy with my posting, I'll be sure to use code tags from now on.
6 years ago
Hi everyone. I'm a pretty big java noob and would really appreciate some assistance. I'm creating a java program that stores data in defined array elements and then sorts them based on their initial string values. I also need to add up the last int value in each array element. I am struggling with how to sort them particularly (I've tried using arrays.sort() method, but recieve a ClastCastException, stating that the class of my array cannot be cast to java.lang.comparable. I don't get any errors when compiling, so I'm kind of at a loss as to how to attack this problem.

Here's my code:
6 years ago