I am a little confused in declaring variable in android, I know two ways of doing it.
1. int EC, CC, PT, HC = 1;
2. int EC = 1, CC = 1, PT = 1, HC = 1;
I want to know the difference between 1 & 2.
Are both the ways same ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This question is not really related to Android, it is only dependent on Java.
Anyway,
the first approach creates the variables
EC, CC, PTandHC.HCgets the value 1.In the second approach you create all the variables and give them the value 1.
Just do a search for Java and Variables if you want to find some information about the subject. Here are two links for you:
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html
http://www.roseindia.net/java/master-java/variables-in-java.shtml
On a side note, you should follow the Java naming conventions and keep your variables lowercase, or capitalize the first letter of any subsequent words in your variable name.