This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Trouble calling this method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Trouble calling this method" Watch "Trouble calling this method" New topic
Author

Trouble calling this method

Mark Captain
Ranch Hand

Joined: Nov 01, 2011
Posts: 30
I am having trouble using this method

Main driver

How do i use the first method?

choice = out.printClosingMessage(???);
D. Ogranos
Ranch Hand

Joined: Feb 02, 2009
Posts: 214
If your method requires an object as parameter, you either need to create the object, or get it from some other method. Like:



Did that answer your question?

Ohh and please, use the code tag (above the edit window) to make code samples easier to read.
Mark Captain
Ranch Hand

Joined: Nov 01, 2011
Posts: 30
Fixed that problem but now I am getting a dead code? error

Nomaan Butt
Ranch Hand

Joined: Oct 19, 2011
Posts: 54


this statement is incorrect, you need to call handleLogin() method of LoginHandler class through its instance

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
Mark Captain wrote: . . .

How do i use the first method? . . .
As far as I am concerned, you don’t. A class should be responsible for itself, so the printClosingMessage should be part of the account class. You would call it like this
account123.printClosingMessage();
or like this
account456.printClosingMessage(out);
depending whether you want to pass it a reference to an Output object or not.

Please avoid coloured text; many people find it difficult to read.
Mark Captain
Ranch Hand

Joined: Nov 01, 2011
Posts: 30
Thanks all for the help tonight, could not have done it with out you!
Everything is working fine =]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
You’re welcome and well done sorting it out.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Trouble calling this method
 
Similar Threads
Unable to put in one of the elements from another arraylist into another class(Resolved)
This may be easy
How to search within a list?
Interfaces and Filter Assignment
TextField input/output across classes