executing return statement in Java

RAWI TEJA SRIPALLI :

My desired output is to print You are in the main method @@@@You have declined to use this application under our terms please try again later But my return statement doesn't print anything What Am I missing? Here is my code

class demo { String applicationOutput(int eeter) {

    if (eeter == 1 )
    {
    System.out.println("You have opted to use this application underour terms");
        return "success and come";
    }
    else
    {
     System.out.println("@@@@You have declined to use this application under our terms");
        return"please try again later";

    }

 }  

} class demo1 {

 public static void main (String[] args)
    {
        System.out.println("You are in the main method");

demo d = new demo();
d.applicationOutput(0);
        }
}

Actual O/p; You are in the main method @@@@You have declined to use this application under our terms

Allanh :

In main you need to add the print element.

System.out.println(d.applicationOutput(0));

I advise you to have one return in your method, something like this:

String applicationOutput(int eeter) {
    String messageReturn = "";
    if (eeter == 1 )
    {
       System.out.println("You have opted to use this application underour terms");
       messageReturn=  "success and come";
    }
    else
    {
        System.out.println("@@@@You have declined to use this application under our terms");
        messageReturn = "please try again later";

    }
    return messageReturn;

 }  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=335338&siteId=1