Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling a method in another methods signature

 
Dan Rh Jones
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

Another question.

I am not sure what to search for about this. My google-fu is not strong.

I want to be able to call one method using another method. However, when I do this (code below) I get a "cannot find symbol" error.

Is what I am trying to do even possible?



Cheers

Dan
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want to nest method calls - sure, that's possible. But you misspelt "sort" as "Sort", and "sort" needs to take a List as parameter, since that is what readFile returns.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47232
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please incorporate Ulf’s suggestions in your code and post it anew.
 
Dan Rh Jones
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Haven't reproduced all of the code as it is for the Java ranch assignments)



produces the following error:

readFile(java.lang.String) in SortNames cannot be applied to (java.util.List)
for (Object string : readFile(blah))
 
Campbell Ritchie
Sheriff
Pie
Posts: 47232
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error about List suggests you might have your own List class.
Major error: why are all those methods static? That is non‑object‑oriented programming. You should have a class which has the List of names as a field, and it can sort its List, display contents, etc.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic