This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
What is difference in the following declarations int i=5; //1 and int i; i=5;//2
I am not clear about what difference you are seeking for anyway here is the difference between the two.There are various places of declarion of variable in a class body. //1 can be declared at instance initializers,in static block,in instance block,in constructors,method body,for-loop body etc. //2 can not be initialized as instance initializers otherwise can be initialized at the places where // can be.