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

Recommended Answers

All 5 Replies

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.

thanks Jwenting.

i have been waiting for a reply. hehehe

were on a tight deadline for our seniors thesis project

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

got it.

its not Set<Char>
but Set<Character>

:)

yes, my bad. I rarely use that type, mostly we use longs where I work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.