0

Hi i have recently encountered a weird return statement in this piece of sample code where ClassA is an abstract class.

public ClassA getClassA()
{
  ClassA A = new ClassB("some value");
  return (A);
}

why is there a bracket around the A variable? Does it signify anything?

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
weejing
  • 173
  • 2
  • 12

1 Answers1

2

No, the parentheses don't mean something. It is the same to do:

return A;

or

return (A);

Parentheses in Java are good for casting and order of operations in math or Boolean logic. Since you are not doing any of those, the parentheses don't matter.

Damian Ugalde
  • 186
  • 1
  • 3
  • 11