944,149 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 10940
  • Java RSS
Jan 27th, 2007
0

unexpected type error

Expand Post »
--------------------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
Similar Threads
Reputation Points: 31
Solved Threads: 0
Junior Poster
Covinus is offline Offline
112 posts
since Mar 2006
Jan 27th, 2007
0

Re: unexpected type error

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.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Jan 27th, 2007
0

Re: unexpected type error

thanks Jwenting.

i have been waiting for a reply. hehehe

were on a tight deadline for our seniors thesis project
Reputation Points: 31
Solved Threads: 0
Junior Poster
Covinus is offline Offline
112 posts
since Mar 2006
Jan 27th, 2007
0

Re: unexpected type error

--------------------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???
Reputation Points: 31
Solved Threads: 0
Junior Poster
Covinus is offline Offline
112 posts
since Mar 2006
Jan 27th, 2007
0

Re: unexpected type error

got it.

its not Set<Char>
but Set<Character>

Reputation Points: 31
Solved Threads: 0
Junior Poster
Covinus is offline Offline
112 posts
since Mar 2006
Jan 27th, 2007
0

Re: unexpected type error

yes, my bad. I rarely use that type, mostly we use longs where I work.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: How to install Apache POI
Next Thread in Java Forum Timeline: java Calculator- wrong calculation





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC