aspose file tools*
The moose likes Beginning Java and the fly likes Calling a method in another methods signature Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Calling a method in another methods signature " Watch "Calling a method in another methods signature " New topic
Author

Calling a method in another methods signature

Dan Rh Jones
Greenhorn

Joined: Aug 16, 2011
Posts: 19
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
Marshal

Joined: Mar 22, 2005
Posts: 42908
    
  69
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

Joined: Oct 13, 2005
Posts: 40027
    
  28
Please incorporate Ulf’s suggestions in your code and post it anew.
Dan Rh Jones
Greenhorn

Joined: Aug 16, 2011
Posts: 19
(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

Joined: Oct 13, 2005
Posts: 40027
    
  28
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.
 
Don't get me started about those stupid light bulbs.
 
subject: Calling a method in another methods signature