Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Need a bit of help with Linked List program

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need a bit of help with Linked List program

    Hey programmers. I've been at this program for a little over two weeks, and could really use some expert help. Basically, I'm trying to read a text file into two integers x and y (which will be used later for coordinates). I've created a vertex class to get/set the x and y coordinates. Lastly, I'm trying to pass the coordinates into a Linked List. I've implemented the Linked List class with helper methods, and everything is fine in that class. In the main program I'm getting an error that says, "cannot find symbol." Please help. I've included code.

     args){
    		CircLinkedList<Vertex> vertexList = new CircLinkedList<Vertex>();
    		String fileName = "test.txt";
    		File file = new File(fileName);
    		try{
    			Scanner inputStream = new Scanner(file);
    			while(inputStream.hasNext()){
    				String data = inputStream.next();
    				String[] values = data.split(",");
    				int x = Integer.parseInt(values[1]);
    				int y = Integer.parseInt(values[2]);
    			}
     
    		inputStream.close();
    		}
    		catch(FileNotFoundException e){
    			System.out.print("File not found");
    		}
     
    		Vertex coordinates = new Vertex(x,y);
    		vertexList.addFirst(coordinates);
     
    	}
     
    }

    and the vertex class

    import java.util.*;
     
     
    public class Vertex {
     
    	int xCord;
    	int yCord;
    	double n;
     
    	public Vertex(int x, int y){
    		xCord = x;
    		yCord = y;
    		n = (Double) null;
    	}
     
    	public int getX(){
    		return xCord;
    	}
     
    	public int getY(){
    		return yCord;
    	}
     
    	public double getN(){
    		return n;
    	}
     
    	public void setX(int x){
    		xCord = x;
    	}
     
    	public void setY(int y){
    		yCord = y;
    	}
     
    	public void setN(double n){
    		this.n = n;
    	}
     
    }

    thanks again.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Need a bit of help with Linked List program

    Post the exact error, the whole thing, copied and pasted.

    "Cannot find symbol" means the compiler encountered a variable name (the 'symbol') that was not declared within the scope it was found. It doesn't know what type the variable is. The error message/stack trace (the thing I asked you to post) will tell you exactly what the offending symbol is, where it was found, etc.

Similar Threads

  1. [Linked List] Problems deleting items from a linked list
    By KLVTZ in forum What's Wrong With My Code?
    Replies: 7
    Last Post: March 8th, 2013, 09:21 PM
  2. [Linked List] Problems deleting items from a linked list
    By KLVTZ in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 8th, 2013, 07:52 PM
  3. Replies: 1
    Last Post: October 25th, 2012, 02:03 PM
  4. Linked list Schminked list help with Nodes Please
    By Bially in forum Collections and Generics
    Replies: 1
    Last Post: September 29th, 2011, 03:20 PM
  5. Linked List Help
    By BuhRock in forum Collections and Generics
    Replies: 3
    Last Post: September 26th, 2011, 08:43 AM