I'm a bit puzzled by the number of developers I see writing methods and classes with curly braces below the class name or the method. What convention are they following?
Sun clearly states that the correct declaration would be:
// this declaration follows sun's conventions
class Sample extends Object {
Sample(int i, int j) {
....
}
}
Yet more and more I see this declared as (even in books):
// this declaration follows a convention I cant identify
class Sample extends Object
{
Sample(int i, int j)
{
....
}
}
And I know that a convention is just a convention and, as long as you follow one, all is good. I'm just looking for the answer on what convention does the latter declaration follow?
This is a standard style convention called the ANSI style. It's common in other languages besides Java, as well.