This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

trying to call a method but cannot find symbol

 
Dustin Schreader
Ranch Hand
Posts: 74
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may be really easy to figure out but I guess i'm not understanding with the following code


I get an error cannot find symbol in the printInformation method. But the printInfo(); seems to work just fine in the print method second from the bottom.
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're trying to call a printInfo method on a String variable. Shouldn't this be a Customer ?
 
Dustin Schreader
Ranch Hand
Posts: 74
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want the method to print the customer info given the customer id number. So i'm trying to create a method that will print that info out.
maybe this helps

This method is from my other class: Customer
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but you didn't get what I'm trying to say

Look at "num.printInfo();". What is "num" ? It's a String. printInfo() is not a method of the String class. Where is that method ? In the Customer class ? Then you have to call it on a customer, not on a String.
 
Dustin Schreader
Ranch Hand
Posts: 74
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so I would want to write it like this?
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes
 
Dustin Schreader
Ranch Hand
Posts: 74
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So now since it's not a string type anymore, how will it be able to print out the correct customer given a customer number (customerNum) string. This is the code from main.
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
customerSearch should return a Customer, instead of returning a boolean. Then you can use the returned value to print the information. If the returned value is null, then the customerId does not exist.
 
Dustin Schreader
Ranch Hand
Posts: 74
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I think I understand the concept. but I still need the original customerSearch method because it is used by another method. So I would make a second customerSearchTwo and have it return Customer.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic