I am reading an existing Java code base right now and I have encountered a strange usage of the return
statement. For example, there is a method isTrue()
that is defined this way:
public boolean isTrue()
{
return(true); //Why? Notice: There is no whitespace between return and (true)
}
In all of the code I've encountered until this point, I've seen
public boolean isTrue()
{
return true; //What I normally see
}
This is pure speculation, but I assume these are the same. So, why would you ever do this? Furthermore is this a particular usage unique to java, or can this type of return be done in other languages? I know this is a fairly trivial question, but things like this will bother me until I know the answer. Thanks!