• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling a method in another methods signature

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please incorporate Ulf’s suggestions in your code and post it anew.
 
Dan Rh Jones
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic