Need some help plz! - Printable Version +- BP Forums (https://bpforums.info) +-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55) +--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56) +---- Forum: Java (https://bpforums.info/forumdisplay.php?fid=19) +---- Thread: Need some help plz! (/showthread.php?tid=597) |
Need some help plz! - bigbubblewrap - 08-09-2012 Hey i was watching Learning java part 14 on YouTube and i followed through with the tutorial line for line, however , eclipse kept telling me i did something wrong. Here's the error: Exception in thread "main" java.lang.Error: Unresolved compilation problem: i cannot be resolved to a variable at AL.PrintArray(AL.java:43) at AL.main(AL.java:20) and here's my code: Code: import java.util.ArrayList; If you can find the problem please do tell i still have not figured it out <!-- s --><img src="{SMILIES_PATH}/icon_e_sad.gif" alt="" title="Sad" /><!-- s --> <!-- s:?: --><img src="{SMILIES_PATH}/icon_question.gif" alt=":?:" title="Question" /><!-- s:?: --> <!-- s:?: --><img src="{SMILIES_PATH}/icon_question.gif" alt=":?:" title="Question" /><!-- s:?: --> <!-- s:!: --><img src="{SMILIES_PATH}/icon_exclaim.gif" alt=":!:" title="Exclamation" /><!-- s:!: --> . -Thanks & your tutorials are great keep it up! <!-- s --><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt="" title="Very Happy" /><!-- s --> Re: Need some help plz! - Vinwarez - 08-10-2012 Hello, bigbubblewrap. The error is in the following code snippet: [code2=java]public static void PrintArray(){ System.out.println("-------------------------"); { System.out.println(i); } }[/code2] You need to add an enhanced FOR loop there. So it should look like this: [code2=java]public static void PrintArray(){ System.out.println("-------------------------"); for (int i : array){ System.out.println(i); } }[/code2] Re: Need some help plz! - bigbubblewrap - 08-10-2012 Thx! it works fine now! <!-- s --><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt="" title="Very Happy" /><!-- s --> <!-- s --><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt="" title="Very Happy" /><!-- s --> Re: Need some help plz! - brandonio21 - 08-10-2012 Yeah, great spot Vinwarez! [code2=java]public static void PrintArray(){ System.out.println("-------------------------"); { System.out.println(i); } }[/code2] Here, when you use the { and }, you are opening and closing a new body... but that is not legal without a body operator such as for, while, if, switch, etc. Re: Need some help plz! - Vinwarez - 08-10-2012 Thanks and No problem. <!-- s --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt="" title="Smile" /><!-- s --> |