Problem with a java error (cannot be applied to (

Posted on 2009-12-28
Last Modified: 2013-12-14
Can anybody help me with this Java problem I'm having.

I have a java file with the following commands.

slip  = new PaySlip(emp,sum);
slipWrite = new PrintWriter(new FileWriter(args[2]));

In the file I have this for the printPay method

      public void printPay()
            double netpay;            
            netpay = gross - tax;

When I go to compile the main app I get printPay() in PaySlip cannot be applied to (

           slip.printPay(slipWrite);  // call printPay to calculate and print payslip

Would you know what this means and how to fix it?

Question by:enigma1234567890
    LVL 40

    Expert Comment

    where are you accepting the Print Writer arguments
    slip.printPay(slipWrite); \\ is passing argument slipWrite

    printPay() \\ no argument
    LVL 40

    Accepted Solution

    public void printPay()
    public void printPay(PrintWriter slipWrite )
    LVL 20

    Expert Comment

    by:Sathish David Kumar N
    can u post the error stack!!
    LVL 2

    Expert Comment

    The method signature of the printPay method is wrong. It should be actually defined as follows

      public void printPay(PrintWriter pw)

    and you can invoke this method as you have used it,


    Expert Comment

    Your method signature is as follows:

    public void printPay();

    This method is not taking any arguments.

    For your code to compile.
    Your method printPay needs to be as follows:
    public void printPay(.PrintWriter pr);


    Author Closing Comment


    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Suggested Solutions

    Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
    The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now