Reputation: 13
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
Upvotes: 1
Views: 50
Reputation: 507
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;
}
Upvotes: 1
Reputation: 311163
Your main method ignores the return value of applicationOutput
. If you want to print it, you'll have to do it there:
System.out.println(d.applicationOutput(0));
Upvotes: 0