Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need some help plz!
#1
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;
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 <!-- sSad --><img src="{SMILIES_PATH}/icon_e_sad.gif" alt="Sad" title="Sad" /><!-- sSad --> <!-- 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! <!-- sBig Grin --><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt="Big Grin" title="Very Happy" /><!-- sBig Grin -->


Messages In This Thread
Need some help plz! - by bigbubblewrap - 08-09-2012, 02:50 PM
Re: Need some help plz! - by Vinwarez - 08-10-2012, 04:29 AM
Re: Need some help plz! - by bigbubblewrap - 08-10-2012, 01:22 PM
Re: Need some help plz! - by Vinwarez - 08-10-2012, 02:09 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)