08-09-2012, 02:50 PM
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:
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 -->
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;
import java.util.Scanner;
public class AL {
static Scanner reader = new Scanner(System.in);
static ArrayList<Integer> array = new ArrayList<Integer>();
public static void main(String[] args)
{
System.out.println("Please enter an array of numbers, type in 0 when finished!");
int in = reader.nextInt();
while (in != 0)
{
array.add(in);
in = reader.nextInt();
}
//The user typed 0
PrintArray();
System.out.println("What number would you like to delete?");
int del = reader.nextInt();
for (int i = 0; i < array.size(); i++)
{
if (array.get(i) == del){
array.remove(i);
break;
}
}
//Break will put us right here
PrintArray();
}
public static void PrintArray()
{
System.out.println("-------------------------");
{
System.out.println(i);
}
}
}
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 -->