Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

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 7 of 7

Threaded View

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post Object as a Reference into Object's Class

    Basically I have:

    A main class:
    public class mainClass 
    {
        public static void main(String[] args) 
        {
            extraClass First=new extraClass("First",1,true);
            extraClass Second=new extraClass("Second",2,true);
            extraClass Third=new extraClass("Third",3,false);
     
            extraClass.compareObjects(First,Second);
        }
    }

    And an extraClass:
    public class extraClass
    {
    	private String objectName;
    	private int objectID;
    	private Boolean isUsed;
     
    	public extraClass(String tempName,int tempID,Boolean tempUsed)
    	{
    		objectName=tempName;
    		objectID=tempID;
    		isUsed=tempUsed;
    	}
     
    	public static void compareObjects(extraClass objectOne,extraClass objectTwo)
    	{
    		if (((objectOne.objectName.equalsIgnoreCase("First")&&(objectTwo.objectName.equalsIgnoreCase("Second"))) || (objectOne.objectName.equalsIgnoreCase("Second"))&&(objectTwo.objectName.equalsIgnoreCase("First"))) && (!Third.checkUsed))
    		{
    			Third.setUsed(Third);
    			System.out.println("Yeah");
    		}
    	}
     
    	public Boolean checkUsed(extraClass tempName)
    	{
    		if (tempName.isUsed)
    			return true;
    		else
    			return false;
    	}
     
    	public void setUsed(extraClass tempName)
    	{
    		tempName.isUsed=true;
    	}
    }


    I'm given the errors:
    cannot find symbol variable Third
    cannot find symbol variable Third
    cannot find symbol variable Third

    The problem is in the compareObjects method in the extraClass when I attempt to use an object I created in the mainClass using the extraClass.
    Any ideas?
    Last edited by Ace Coder; November 28th, 2010 at 03:54 PM.


Similar Threads

  1. Object or Class?
    By mortalc in forum Object Oriented Programming
    Replies: 23
    Last Post: August 20th, 2010, 01:17 AM
  2. How to create a new object of another class within a method
    By davie in forum Object Oriented Programming
    Replies: 1
    Last Post: April 16th, 2010, 05:53 PM
  3. Object as Reference not working
    By jassi in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 9th, 2010, 09:47 AM
  4. Class and Object
    By jyothishey in forum Object Oriented Programming
    Replies: 2
    Last Post: January 25th, 2010, 08:48 AM
  5. Replies: 2
    Last Post: November 5th, 2009, 10:15 PM