unexpected type error

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2006
Posts: 112
Reputation: Covinus is an unknown quantity at this point 
Solved Threads: 0
Covinus's Avatar
Covinus Covinus is offline Offline
Junior Poster

unexpected type error

 
0
  #1
Jan 27th, 2007
--------------------Configuration: <Default>--------------------
C:\Documents and Settings\mykel\Desktop\auto.java:4: unexpected type
found : char
required: reference
Set <char>setAlpha = new HashSet<char>();
^
C:\Documents and Settings\mykel\Desktop\auto.java:4: unexpected type
found : char
required: reference
Set <char>setAlpha = new HashSet<char>();
^
2 errors

how come i cant cast a char on a set??? it works well with other data types.

thanks in advance
if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: unexpected type error

 
0
  #2
Jan 27th, 2007
char is a primitive, you can't store primitives in Collections.
Make it Set<Char> instead, and autoboxing will ensure your chars are converted into Chars and back again.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 112
Reputation: Covinus is an unknown quantity at this point 
Solved Threads: 0
Covinus's Avatar
Covinus Covinus is offline Offline
Junior Poster

Re: unexpected type error

 
0
  #3
Jan 27th, 2007
thanks Jwenting.

i have been waiting for a reply. hehehe

were on a tight deadline for our seniors thesis project
if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 112
Reputation: Covinus is an unknown quantity at this point 
Solved Threads: 0
Covinus's Avatar
Covinus Covinus is offline Offline
Junior Poster

Re: unexpected type error

 
0
  #4
Jan 27th, 2007
--------------------Configuration: <Default>--------------------
C:\Documents and Settings\mykel\Desktop\auto.java:4: cannot find symbol
symbol : class Char
location: class auto
Set <Char>s = new HashSet<Char>();
^
C:\Documents and Settings\mykel\Desktop\auto.java:4: cannot find symbol
symbol : class Char
location: class auto
Set <Char>s = new HashSet<Char>();
^
2 errors

whats autoboxing???
if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 112
Reputation: Covinus is an unknown quantity at this point 
Solved Threads: 0
Covinus's Avatar
Covinus Covinus is offline Offline
Junior Poster

Re: unexpected type error

 
0
  #5
Jan 27th, 2007
got it.

its not Set<Char>
but Set<Character>

if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: unexpected type error

 
0
  #6
Jan 27th, 2007
yes, my bad. I rarely use that type, mostly we use longs where I work.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC