For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.
Why do you have a semicolon after the function body for Arraylist2Decimal()?
}};
static void Arraylist2Decimal() {
for (int i = 1; i == SEPARATED1.size() + 1; i++) {
Here, i is initialized to 1.
the testing condition for the FOR loop to iterate is set to i == the size of SEPARATED1 plus 1. So only if the size of SEPERATED1 is 0 it will meet the condition to go into the loop.
Change it to
for (int i = 1; i <= SEPARATED1.size() + 1; i++) {
int intValue = (int) SEPARATED1.get(i);
Point - 1:
ArrayList indexing starts at 0.
If you loop starting at 1, you will be ignoring the first value in the arraylist.
Point -2 :
The loop is set to run until i == SEPARATED1.size() + 1, which is one index more than the size. This will throw an exception.
It should be
for (int i = 0; i <= SEPARATED1.size() + 1; i++) {
but what happened, is that my program completely ignores the "Arraylist2Decimal" method even after called.I will be really grateful if someone could help me.(Using netbeans IDE)
but what happened, is that my program completely ignores the "Arraylist2Decimal" method even after called.
I will be really grateful if someone could help me.
(Using netbeans IDE)
All you have to do is step through the code one line at a time and watch/examine what is happening.
If you need help using the debugger in NetBeans read the documentation and then post your question on a NetBeans forum.
Thanks for all the help. Every single answer above was right(But now I'm not sure on what answer I should tag as the correct answer.). after implementing the changes, now my code works fine.
And specially to rp0428 for telling me about the debugger. If you didnt tell me about this, I would never know that the arraylist starts at 0 while its size starts counting at 1.