• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java errors  RSS feed

 
Nikki Smith
Ranch Hand
Posts: 65
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm struggling to understand why I keep getting the following errors:

/tmp/java_PMx2uB/BookOrder.java:28: error: method setAuthor(String) is already defined in class BookOrder
    public void setAuthor(String auth) {
                ^
/tmp/java_PMx2uB/BookOrder.java:32: error: method getAuthor() is already defined in class BookOrder
    public int getAuthor() {
               ^
/tmp/java_PMx2uB/BookOrder.java:17: error: incompatible types: String cannot be converted to int
return author;
       ^
/tmp/java_PMx2uB/BookOrder.java:25: error: incompatible types: String cannot be converted to int
return title;
       ^
/tmp/java_PMx2uB/BookOrder.java:33: error: incompatible types: String cannot be converted to int
return author;
       ^
5 errors


What does it mean 'it's already defined? I've barely gotten anything put together, so where is it getting that it's already defined? And why does it say I'm  trying to convert a String to an int? my setQuantity is void and takes an int parameter and the get quantity has a return data type of int. I don't see any place that's converting String to int. This is so frustrating. =/ I googled how to use setters and getters and even copied one setter from the tutorials point site and replaced it with my variables and it didn't work, but if I used it with their variables it did.

 
Nikki Smith
Ranch Hand
Posts: 65
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nevermind, I fumbled it all up when I had to move stuff around. Found where it's messing up. I haven't really been able to make much sense of most IDE's and keep messing projects up on them so had to move this to np++ and it's gotten all kinds of mixed up. I was trying to figure out how to use IntelliJ, which wasn't working out very well.
 
Campbell Ritchie
Marshal
Posts: 56581
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done sorting it out
What's np++? NotePad++? (I think it is a really good program, by the way, but the abbreviation is unfamiliar.) You now know why we recommend not to use IDEs at a beginning stage: the learning curve is too steep.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!