This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 41083
    
  43
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.


Ping & DNS - my free Android networking tools app
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37945
    
  22
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: 37945
    
  22
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.
 
 
subject: Calling a method in another methods signature
 
Similar Threads
How can I create an object based on input
Java: Convert a binary file to "text" and back again.
File IO can't handle Strings?
Different classes in different directories.
Reading from a file to a bidimensional array