Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convention for methods declaration in Java

Is there a convention in Java on where to declare fields - before or after methods?

like image 984
Eugene Avatar asked Jan 21 '23 17:01

Eugene


1 Answers

Class layout: see here http://java.sun.com/docs/codeconv/html/CodeConventions.doc2.html#1852

The following table describes the parts of a class or interface declaration, in the order that they should appear

  1. Class/interface documentation comment (/*.../)
  2. class or interface statement
  3. Class/interface implementation comment (/.../), if necessary
  4. Class (static) variables
  5. Instance variables
  6. Constructors
  7. Methods
like image 178
Nishant Avatar answered Jan 23 '23 08:01

Nishant