Results 1 to 9 of 9
  1. #1
    sneeak is offline Member
    Join Date
    Aug 2011
    Posts
    8
    Rep Power
    0

    Default Linked List Help

    Hi I am new to Java and am trying to implement a Linked List in my program that reads from a text file(external source).

    Here is the code I have typed, I have got an error saying cannot find symbol Property within my java program. The external text file is called Property.txt, if anyone could guide me as to what I have done wrong I would appreciate it.

    Java Code:
    public static void main (String[]args)
    	{
    
    		PropertyManager myManager = new PropertyManager();
    		myManager.setVisible(true);
    		myManager.setSize(new Dimension(750, 600));
    
    
    		LinkedList<String> property = new LinkedList<String>();
    		int size = property.size();
    		for(int i=0;i<property.size();++i)
    		{
    				property.add("463,Sold,James Smith,12/01/10,14 River road Norman Gardens Q4701");
    				property.add("118,Sale,Arthur London,20/01/10,51 Coast street Frenchville Q4701");
    				property.add("200,Deposit taken,Scott Jones,30/01/10,11 Airport road Rockhampton Q4700");
    				property.add("129,offer received,Andy Roberts,05/12/09,9 South avenue Rockhampton Q4700");
    				property.add("123,Sale,Joshua Lincoln,15/12/09,3 Mackay road Frenchville Q4701");
    				property.add("124,Sale,Michael Green,12/12/10,33 Georginia court Glenlee Q4701");
    				property.add("167,under contract,Peter Lee,11/09/10,14 Friendly drive Glenmore Q4701");
    				property.add("201,Sold,Euller Patel,22/01/11,5 Sunrise avenue Norman Gardens Q4701");
    				property.add("500,Sale,Kim Johnson,19/12/10,87 Bluesky court Rockhampton Q4702");
    
    				Property p = (Property)property.get(i);
    		}
    
    	} //main

    I:\PropertyManager.java:211: error: cannot find symbol
    Property p = (Property)property.get(i);
    ^
    symbol: class Property
    location: class PropertyManager
    I:\PropertyManager.java:211: error: cannot find symbol
    Property p = (Property)property.get(i);
    ^
    symbol: class Property
    location: class PropertyManager
    2 errors

    Tool completed with exit code 1

    Please excuse me if the error is so simple, if it is I apologize as I am really new to Java and have based most of my code from a book that I have been studying.
    Last edited by sneeak; 08-08-2011 at 02:17 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,789
    Rep Power
    25

    Default

    Where is the class Property defined? The compiler can not find its definition.
    You need to add code to define a class name Property.

  3. #3
    sneeak is offline Member
    Join Date
    Aug 2011
    Posts
    8
    Rep Power
    0

    Default

    Ok so i think I made a typo its now: PropertyManager p = (PropertyManager)property.get(i);
    ^
    I am getting an error that says..
    java:126: error: inconvertible types

    It says something about casting wrong?

    What would I have to do to fix the error?
    Last edited by sneeak; 08-08-2011 at 02:42 PM.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,789
    Rep Power
    25

    Default

    Which variables are the incompatible types?
    What type does the get() method return?

    When posting error messages, please post the FULL text of the error message. Don't leave parts of it off.

  5. #5
    sneeak is offline Member
    Join Date
    Aug 2011
    Posts
    8
    Rep Power
    0

    Default

    That is the error message the little arrow is pointing at get(i);

    I:\PropertyManager.java:130: error: inconvertible types
    PropertyManager p = (PropertyManager)property.get(i);
    ^
    required: PropertyManager
    found: String
    1 error

    Tool completed with exit code 1

    and I havent set a return method for get() I dont think

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,789
    Rep Power
    25

    Default

    I havent set a return method for get()
    The get() method is for the LinkedList<String> object. That class defines what get() returns.

    What value do you expect to "get" from the property object? It contains Strings.

  7. #7
    sneeak is offline Member
    Join Date
    Aug 2011
    Posts
    8
    Rep Power
    0

    Default

    Sorry wasnt at PC, i expect to get a string from a string within a textfile and then compare it with a string entered in a textfield, which when the button is pressed it compares the string to the textfile to the one entered in the textfield, then displays it in the second textarea.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,789
    Rep Power
    25

    Default

    Java Code:
    PropertyManager p = (PropertyManager)property.get(i);
    What is the purpose of the above?
    You last post#7 says that you are working with Strings. It says nothing about the PropertyManager class.

  9. #9
    JeffGrigg is offline Member
    Join Date
    Aug 2011
    Posts
    95
    Rep Power
    0

    Default

    If it did compile, it wouldn't do anything, as it would never get into the loop. (Heck; it wouldn't even throw a ClassCastException. ;-)

    It might make more sense to do things in this order:
    Java Code:
    		LinkedList<String> property = new LinkedList<String>();
    
    		property.add("463,Sold,James Smith,12/01/10,14 River road Norman Gardens Q4701");
    		property.add("118,Sale,Arthur London,20/01/10,51 Coast street Frenchville Q4701");
    		property.add("200,Deposit taken,Scott Jones,30/01/10,11 Airport road Rockhampton Q4700");
    		property.add("129,offer received,Andy Roberts,05/12/09,9 South avenue Rockhampton Q4700");
    		property.add("123,Sale,Joshua Lincoln,15/12/09,3 Mackay road Frenchville Q4701");
    		property.add("124,Sale,Michael Green,12/12/10,33 Georginia court Glenlee Q4701");
    		property.add("167,under contract,Peter Lee,11/09/10,14 Friendly drive Glenmore Q4701");
    		property.add("201,Sold,Euller Patel,22/01/11,5 Sunrise avenue Norman Gardens Q4701");
    		property.add("500,Sale,Kim Johnson,19/12/10,87 Bluesky court Rockhampton Q4702");
    
    		int size = property.size();
    		for(int i=0;i<property.size();++i)
    		{
    			String p = (String)property.get(i);
    			System.out.println(p);
    		}

Similar Threads

  1. Replies: 4
    Last Post: 02-21-2011, 10:34 AM
  2. Need help using linked list
    By tigertomas in forum New To Java
    Replies: 5
    Last Post: 02-12-2011, 04:22 PM
  3. Linked list inside a linked list
    By viperlasson in forum New To Java
    Replies: 5
    Last Post: 07-27-2010, 12:15 AM
  4. Need help in linked list
    By Hotzero in forum New To Java
    Replies: 17
    Last Post: 06-05-2010, 09:13 AM
  5. Linked List integer list
    By igniteflow in forum Advanced Java
    Replies: 1
    Last Post: 12-10-2008, 09:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •