Re: Unable to get the idea
Quote:
for ( int answer = 0; answer < responses.length; answer++ )
You need to read the tutorial or your text about how for loops work. This is fairly standard in many computer languages.
Go to this site and Find "for statement" Trail: Learning the Java Language: Table of Contents (The Java™ Tutorials)
Re: Unable to get the idea
Thanks for the reply but i am not talking abount loop statement, I am talking abount the below code after loop statement.
Quote:
++frequency[ responses[ answer ] ];
Re: Unable to get the idea
His issue is with this statement:
Code:
++frequency[ responses[ answer ] ];
My suggestion is that you split this up into several lines to better understand it.
Code:
int thisAnswer = responses[answer];
++frequency[thisAnswer];
Note that
Code:
++frequency[thisAnswer];
is the same as
Code:
frequency[thisAnswer] = frequency[thisAnswer] + 1;
Re: Unable to get the idea
Dyslexia, or need new glasses.
Re: Unable to get the idea
Thanks for the reply, could you please explain it in more details, actually, I am always afraid from array topic and this time I dont want to compromise it.
If you can provide me an example then I will really appreciate you.
Re: Unable to get the idea
Consider using a debugger such as one that is available from NetBeans or Eclipse (or likely whatever IDE you're using) and step through the code to see what happens to the frequency array at that line as this can tell you a lot.
Re: Unable to get the idea
I am using Eclipse but i dont know how debugger works, will try to see the values in debugger and then let you the exact situation. Thank you very much