It is the correct way write the code.
E.g.: public int sum (int x) {...} 》corret way.
int public sum ( int x) {...} 》wrong code. The Symtax say for us the corret place to put the words (key-words). For example, first the modifier [public, private, protected, or "anyone"] then the return type [int, float, void, double, ...], and then the method's name, and then the "(" and arguments and then ")".