new instance problem

  • Follow


I created a class called

public class AVLTree
 implements Tree
{

}

and when it try to create a instance of this

AVLTree AvlMember = new AVLTree();

it says cannot resolve symbol class AVLTree.

I'm trying create it in another class and it seems to package correctly I
just can't seem to figure why it doesn't  recognize it.


0
Reply Email67 (21) 5/15/2004 2:49:16 PM

On Sat, 15 May 2004 14:49:16 GMT, jova wrote:

> I created a class called
> 
> public class AVLTree

...really?  

> I'm trying create it in another class 

You mean the same .java _file_?

It won't work.  Every public class
needs to be in a separate file of name
'ClassName.java'.

> ...and it seems to package correctly ..

??  <http://www.physci.org/codes/javafaq.jsp#specific>

>..I just can't seem to figure why it doesn't  recognize it.

Perhaps you should figure the location of..
<http://www.physci.org/codes/javafaq.jsp#cljh>
first..

If the suggestion above does not solve it,
you may need also to resort to actual code..
<http://www.physci.org/codes/sscce.jsp>

-- 
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
0
Reply SeeMySites (3836) 5/15/2004 2:58:13 PM


I have them in separate .java files.
"Andrew Thompson" <SeeMySites@www.invalid> wrote in message
news:10b2gld1boqyn.dbp37j7j1i3z$.dlg@40tude.net...
> On Sat, 15 May 2004 14:49:16 GMT, jova wrote:
>
> > I created a class called
> >
> > public class AVLTree
>
> ..really?
>
> > I'm trying create it in another class
>
> You mean the same .java _file_?
>
> It won't work.  Every public class
> needs to be in a separate file of name
> 'ClassName.java'.
>
> > ...and it seems to package correctly ..
>
> ??  <http://www.physci.org/codes/javafaq.jsp#specific>
>
> >..I just can't seem to figure why it doesn't  recognize it.
>
> Perhaps you should figure the location of..
> <http://www.physci.org/codes/javafaq.jsp#cljh>
> first..
>
> If the suggestion above does not solve it,
> you may need also to resort to actual code..
> <http://www.physci.org/codes/sscce.jsp>
>
> -- 
> Andrew Thompson
> http://www.PhySci.org/ Open-source software suite
> http://www.PhySci.org/codes/ Web & IT Help
> http://www.1point1C.org/ Science & Technology


0
Reply Email67 (21) 5/15/2004 3:05:37 PM

On Sat, 15 May 2004 15:05:37 GMT, jova wrote:

Please do not top-post jova, 
<http://www.physci.org/codes/javafaq.jsp#netiquette>

My comments all way to the bottom..

> "Andrew Thompson" <SeeMySites@www.invalid> wrote in message
>> On Sat, 15 May 2004 14:49:16 GMT, jova wrote:
>>
>>> I created a class called
>>> public class AVLTree
>>> I'm trying create it in another class
>>
>> You mean the same .java _file_?

> I have them in separate .java files.

OK.. so you mean you are trying to
create an instance of AVLTree from
a different class?  Like..

AVLTree tree = new AVLTree();

Code speakes a thousand words jova, especially
<http://www.physci.org/codes/sscce.jsp>

Make us an example.  

You should be able to do 
it in under 40 lines.

-- 
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
0
Reply SeeMySites (3836) 5/15/2004 3:14:41 PM

"jova" <Email@nospam.net> wrote in message
news:M5qpc.62600$wY.44130@nwrdny03.gnilink.net...
> I created a class called
>
> public class AVLTree
>  implements Tree
> {
>
> }
>
> and when it try to create a instance of this
>
> AVLTree AvlMember = new AVLTree();
>
> it says cannot resolve symbol class AVLTree.
>
> I'm trying create it in another class and it seems to package correctly I
> just can't seem to figure why it doesn't  recognize it.
>
>

I thought I showed you an example of what i done in my first posting I know
it wasn't worded clearly.  I didn't post all the code.  Because it's kind of
long. But, yeah I trying to create an instance of my AVLTree in another
class and it doesn't recognize the AVLTree.  Is there anything else I should
look at. besides the spelling of the name because I can't figure what else
could make it no be recognize.


0
Reply Email67 (21) 5/15/2004 3:32:50 PM

On Sat, 15 May 2004 15:32:50 GMT, jova wrote:

>..But, yeah I trying to create an instance of my AVLTree in another
> class and it doesn't recognize the AVLTree.  Is there anything else I should
> look at. 

Yes.

> I didn't post all the code.  Because it's kind of
> long. 

<http://www.physci.org/codes/sscce.jsp>

Good luck..

-- 
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
0
Reply SeeMySites (3836) 5/15/2004 4:32:07 PM

ok here is a sample of my AVLTree code.

package committeePage;
import java.io.*;
import java.awt.*;
import adt.*;
import link.*;

public class AVLTree
 implements Tree
{
    protected AVLTree leftT;
    protected AVLTree rightT;
    protected AVLTree parent;
    protected Member key; /*nodes contain a Member*/
    private int leftHeight =0 , rightHeight =0;
    public static final int BALANCE=0;
    public static final int NO_BALANCE=1;
    public int rotationNeeded=0;
    public int balanceFlag=0;
    public int flag=0;

    //New tree without any arguments
    public AVLTree()
    {
        leftT = null;
        rightT = null;
        parent = null;
        key = null;
        leftHeight = 0;
        rightHeight = 0;
    }
    public AVLTree(AVLTree rbt)
    {
        leftT = rbt.leftT;
        rightT = rbt.rightT;
        parent = rbt.parent;
        key = rbt.key;
        leftHeight = rbt.leftHeight;
        rightHeight = rbt.rightHeight;
    }
    //New tree with a root value
    public AVLTree(Member i)
    {
        leftT = null;
        rightT = null;
        parent = null;
        key = i;
        leftHeight = 0;
        rightHeight = 0;
    }

}

and here is where I define a instance of the AVLTree

package committeePage;
import java.util.*;
import link.*;
import adt.*;

class Committee
{
 AVLTree member = new AVLTree();
 SearchTreeMember TreeMembers = new SearchTreeMember();
 SearchMember members = new SearchMember();
 SearchMember sortedMembers = new SearchMember();
 HashMember Hmembers = new HashMember();
}

when I try to compile the Committee class it tells me that it doesn't
recognizes of the AVLTree.


0
Reply Email67 (21) 5/15/2004 8:01:20 PM

jova wrote:
> ok here is a sample of my AVLTree code.
> 
> package committeePage;

Here's your problem. When you compile, use '-d .' argument to javac.
That will create the class file in the committePage subdirectory.
Then run it with 'java committeePage.<class>'.

0
Reply bitbucket44 (1434) 5/15/2004 8:09:36 PM


Oh the Committee class won't compile, but the AVLTree class will compile.
"Sudsy" <bitbucket44@hotmail.com> wrote in message
news:40A67900.1010800@hotmail.com...
> jova wrote:
> > ok here is a sample of my AVLTree code.
> >
> > package committeePage;
>
> Here's your problem. When you compile, use '-d .' argument to javac.
> That will create the class file in the committePage subdirectory.
> Then run it with 'java committeePage.<class>'.
>

i'm using JCreator and don't know how to '-d' as an argument to javac


0
Reply Email67 (21) 5/15/2004 8:18:23 PM

jova wrote:
<snip>
> i'm using JCreator and don't know how to '-d' as an argument to javac

I'm not familiar with that app so the best I could suggest for the
nonce is to remove the package declarations. Could you try that and
let us know the results?
Hopefully someone with JCreator experience will chime in and let you
know the definitive solution.

0
Reply bitbucket44 (1434) 5/15/2004 10:13:03 PM

jova schrieb:
> Oh the Committee class won't compile, but the AVLTree class will compile.
> "Sudsy" <bitbucket44@hotmail.com> wrote in message
> news:40A67900.1010800@hotmail.com...
> 
>>jova wrote:
>>
>>>ok here is a sample of my AVLTree code.
>>>
>>>package committeePage;
>>
>>Here's your problem. When you compile, use '-d .' argument to javac.
>>That will create the class file in the committePage subdirectory.
>>Then run it with 'java committeePage.<class>'.
>>
> 
> 
> i'm using JCreator and don't know how to '-d' as an argument to javac
> 
> 

Assume a "root" directory called src. Then organize it as follows

src
  |
  +--committeePage
          +
          |
          +- AVLTree.java
          |
          +- Committee.java

Change into directory src and then call

javac committeePage\*.java

Bye
Michael

0
Reply michlmann (357) 5/15/2004 10:52:45 PM

10 Replies
14 Views

(page loaded in 2.018 seconds)


Reply: