Return Keyword In Java
It's another Friday and a festive one too. So first of all, Merry Christmas to all the readers. Since it's a big festive day, I'll keep this blog a very, very short one.
Yes, as the title goes, it is about the "return" keyword in Java.
What is a return keyword? Return is a unique keyword. When encountered ends the main. That means no statement will be executed after the return statement.
Let's understand it with a simple example:
public static void main(String[] args)
{
int a=10;
if(a>5){
System.out.println("Hello");
return;
}
System.out.println("Hi");
}
Output:
Hello
From the above example, we see that program execution stops at the return statement. And the next print statement, which was supposed to print "Hi," doesn't executes.
So, this was it in this week's blog. Enjoy the festival and see you next Friday.
No Comments Yet