p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_java thread: RE: Cannot Resolve Symbol (HashSet)


Message #1 by Chanoch Wiggers <ChanochW@w...> on Mon, 8 Apr 2002 11:10:28 +0100
you probably have to import the class?

-----Original Message-----
From: Peak, Jason [mailto:jasonp@p...]
Sent: 05 April 2002 18:32
To: Beginning Java
Subject: [beginning_java] Cannot Resolve Symbol (HashSet)


Hey all, I'm running J2SE 1.4 on Windows 98.  I have this class which I got
from a session at JavaOne which I can't get to compile.  It keeps erroring
out stating "cannot resolve symbol  Symbol:  class HashSet  Location:  class
Name  Set s = new HashSet();".  This code was brough up in a programming
puzzlers session.  Here's the code for the class:
Message #2 by "Ivor Horton" <ivor.horton@b...> on Sun, 7 Apr 2002 20:30:28 +0100
Most likely it is because you need an import statement for the HashSet class
name:

import java.util.HashSet;


Ivor


Message #3 by "John B. Spindler" <spindler@k...> on Sun, 7 Apr 2002 10:36:31 +0900
Add import java.util.*; at the top of your class and it will compile
just fine.

John B. Spindler
Systems Engineer
KDDI Okinawa Co., Ltd.
Local: 926-2754
Commercial: 011-81-98-926-2754
spindler@k...


-----Original Message-----
From: Peak, Jason [mailto:jasonp@p...] 
Sent: Saturday, April 06, 2002 2:32 AM
To: Beginning Java
Subject: [beginning_java] Cannot Resolve Symbol (HashSet)


Hey all, I'm running J2SE 1.4 on Windows 98.  I have this class which I
got from a session at JavaOne which I can't get to compile.  It keeps
erroring out stating "cannot resolve symbol  Symbol:  class HashSet
Location:  class Name  Set s = new HashSet();".  This code was brough up
in a programming puzzlers session.  Here's the code for the class:

public class Name {
        private String first, last;

        public Name(String first, String last) {
                this.first = first;
                this.last = last;
        }

        public boolean equals(Object o) {
                if (!(o instanceof Name)) return false;
                Name n = (Name)o;
                return n.first.equals(first) && n.last.equals(last);
        }

        public static void main(String[] args) {
        Set s = new HashSet();
        s.add(new Name("Donald", "Duck"));
        System.out.println(
                s.contains(new Name("Donald", "Duck")));
        }

}


Jason W. Peak		 	jasonp@p...
System Administrator
Placon Corp.			voice:  (xxx) xxx-xxxx
6096 McKee Road
Madison, WI 53719-5114		fax:     (xxx) xxx-xxxx

Please visit us at http://www.placon.com

---
Do you need true END-TO-END (e2e) Java Messaging (JMS)?  Softwired
offers industry's ONLY complete 100% JMS messaging solutions for your
needs TODAY. Visit
http://adtracking.wrox.com/track.asp?x=p2p%2Fe%2Fjava%2Dsoftwired&url=ww
w.softwired-inc.com Our unique product range includes: iBus//Mobile
(wireless data), iBus//MessageBus (IP Multicast), iBus//MessageServer
(store and forward) and much more!



Message #4 by "Michael Stout" <javaappleseed@h...> on Fri, 05 Apr 2002 13:35:48 -0800
I compiled it by placing
import java.util.*;
before the class
public class Name {
// class body
}

>From: "Peak, Jason" <jasonp@p...>
>Reply-To: "Beginning Java" <beginning_java@p...>
>To: "Beginning Java" <beginning_java@p...>
>Subject: [beginning_java] Cannot Resolve Symbol (HashSet)
>Date: Fri, 5 Apr 2002 11:31:36 -0600
>
>Hey all, I'm running J2SE 1.4 on Windows 98.  I have this class which I got
>from a session at JavaOne which I can't get to compile.  It keeps erroring
>out stating "cannot resolve symbol  Symbol:  class HashSet  Location:  
>class
>Name  Set s = new HashSet();".  This code was brough up in a programming
>puzzlers session.  Here's the code for the class:
>
>public class Name {
>         private String first, last;
>
>         public Name(String first, String last) {
>                 this.first = first;
>                 this.last = last;
>         }
>
>         public boolean equals(Object o) {
>                 if (!(o instanceof Name)) return false;
>                 Name n = (Name)o;
>                 return n.first.equals(first) && n.last.equals(last);
>         }
>
>         public static void main(String[] args) {
>         Set s = new HashSet();
>         s.add(new Name("Donald", "Duck"));
>         System.out.println(
>                 s.contains(new Name("Donald", "Duck")));
>         }
>
>}
>
>
>Jason W. Peak		 	jasonp@p...
>System Administrator
>Placon Corp.			voice:  (xxx) xxx-xxxx
>6096 McKee Road
>Madison, WI 53719-5114		fax:     (xxx) xxx-xxxx
>
>Please visit us at http://www.placon.com
>
>---
>Do you need true END-TO-END (e2e) Java Messaging (JMS)?  Softwired
>offers industry's ONLY complete 100% JMS messaging solutions for your
>needs TODAY.
>Visit 
>http://adtracking.wrox.com/track.asp?x=p2p%2Fe%2Fjava%2Dsoftwired&url=www.softwired-inc.com 
>Our unique product range includes: iBus//Mobile (wireless data),
>iBus//MessageBus (IP Multicast), iBus//MessageServer (store and forward)
>and much more!
>




_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

Message #5 by "Peak, Jason" <jasonp@p...> on Fri, 5 Apr 2002 11:31:36 -0600
Hey all, I'm running J2SE 1.4 on Windows 98.  I have this class which I got
from a session at JavaOne which I can't get to compile.  It keeps erroring
out stating "cannot resolve symbol  Symbol:  class HashSet  Location:  class
Name  Set s = new HashSet();".  This code was brough up in a programming
puzzlers session.  Here's the code for the class:

public class Name {
        private String first, last;

        public Name(String first, String last) {
                this.first = first;
                this.last = last;
        }

        public boolean equals(Object o) {
                if (!(o instanceof Name)) return false;
                Name n = (Name)o;
                return n.first.equals(first) && n.last.equals(last);
        }

        public static void main(String[] args) {
        Set s = new HashSet();
        s.add(new Name("Donald", "Duck"));
        System.out.println(
                s.contains(new Name("Donald", "Duck")));
        }

}


Jason W. Peak		 	jasonp@p...
System Administrator
Placon Corp.			voice:  (xxx) xxx-xxxx
6096 McKee Road
Madison, WI 53719-5114		fax:     (xxx) xxx-xxxx

Please visit us at http://www.placon.com
Message #6 by "Peak, Jason" <jasonp@p...> on Fri, 5 Apr 2002 16:27:54 -0600
Worked like a charm...thanks.


Jason W. Peak		 	jasonp@p...
System Administrator
Placon Corp.			voice:  (xxx) xxx-xxxx
6096 McKee Road
Madison, WI 53719-5114		fax:     (xxx) xxx-xxxx

Please visit us at http://www.placon.com


-----Original Message-----
From: Michael Stout [mailto:javaappleseed@h...]
Sent: Friday, April 05, 2002 3:36 PM
To: Beginning Java
Subject: [beginning_java] Re: Cannot Resolve Symbol (HashSet)


I compiled it by placing
import java.util.*;
before the class
public class Name {
// class body
}

>From: "Peak, Jason" <jasonp@p...>
>Reply-To: "Beginning Java" <beginning_java@p...>
>To: "Beginning Java" <beginning_java@p...>
>Subject: [beginning_java] Cannot Resolve Symbol (HashSet)
>Date: Fri, 5 Apr 2002 11:31:36 -0600
>
>Hey all, I'm running J2SE 1.4 on Windows 98.  I have this class which I got
>from a session at JavaOne which I can't get to compile.  It keeps erroring
>out stating "cannot resolve symbol  Symbol:  class HashSet  Location:  
>class
>Name  Set s = new HashSet();".  This code was brough up in a programming
>puzzlers session.  Here's the code for the class:
>
>public class Name {
>         private String first, last;
>
>         public Name(String first, String last) {
>                 this.first = first;
>                 this.last = last;
>         }
>
>         public boolean equals(Object o) {
>                 if (!(o instanceof Name)) return false;
>                 Name n = (Name)o;
>                 return n.first.equals(first) && n.last.equals(last);
>         }
>
>         public static void main(String[] args) {
>         Set s = new HashSet();
>         s.add(new Name("Donald", "Duck"));
>         System.out.println(
>                 s.contains(new Name("Donald", "Duck")));
>         }
>
>}
>
>
>Jason W. Peak		 	jasonp@p...
>System Administrator
>Placon Corp.			voice:  (xxx) xxx-xxxx
>6096 McKee Road
>Madison, WI 53719-5114		fax:     (xxx) xxx-xxxx
>
>Please visit us at http://www.placon.com
>
>---
>Do you need true END-TO-END (e2e) Java Messaging (JMS)?  Softwired
>offers industry's ONLY complete 100% JMS messaging solutions for your
>needs TODAY.
>Visit 
>http://adtracking.wrox.com/track.asp?x=p2p%2Fe%2Fjava%2Dsoftwired&url=www.s
oftwired-inc.com 
>Our unique product range includes: iBus//Mobile (wireless data),
>iBus//MessageBus (IP Multicast), iBus//MessageServer (store and forward)
>and much more!
>




_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


---
Do you need true END-TO-END (e2e) Java Messaging (JMS)?  Softwired
offers industry's ONLY complete 100% JMS messaging solutions for your
needs TODAY.
Visit
http://adtracking.wrox.com/track.asp?x=p2p%2Fe%2Fjava%2Dsoftwired&url=www.so
ftwired-inc.com Our unique product range includes: iBus//Mobile (wireless
data),
iBus//MessageBus (IP Multicast), iBus//MessageServer (store and forward)
and much more!


  Return to Index