Order of declaring a variable, methods and main-method in Java
I'm having problems to figure out if the order of declaring a variable, methods and main-method matters. What to put first? General code: Public class orderOfMethods { int a = 5 // declaring variables first? int b = 10 public static void main(String[] args) { // Then the main-method? if (a<b) { ...} //if a < b, then execute method 1 else if (a=b) { ...} // if a = b, then execute method 2 else { ...} // if a>b ,then execute method 3 } Class method1 { ...} // And after that the methods that are needed in the main-method? Class method2 { ...} // Class method3 { ...} // } I have 2 questions: 1. Does Java accept the code I wrote? So is it ok to first put a reference to method 1, 2 and 3 and after that give orders for these methods? 2. What is the most common / most practical way to write a code so it doesn't get a messy code? In other words: is there a better way to order methods etc.?