Click here to Skip to main content
15,893,266 members
Home / Discussions / Java
   

Java

 
GeneralRe: Problem in Multithreading ,,.... Pin
TorstenH.7-Jul-11 22:42
TorstenH.7-Jul-11 22:42 
AnswerRe: Problem in Multithreading ,,.... Pin
David Skelly7-Jul-11 22:28
David Skelly7-Jul-11 22:28 
GeneralRe: Problem in Multithreading ,,.... Pin
gateway237-Jul-11 23:07
gateway237-Jul-11 23:07 
AnswerRe: Problem in Multithreading ,,.... Pin
Ashish Tyagi 4013-Jul-11 7:04
Ashish Tyagi 4013-Jul-11 7:04 
QuestionLoadin page while transferring control from one jsp to another jsp Pin
yog.khopade6-Jul-11 23:31
yog.khopade6-Jul-11 23:31 
AnswerRe: Loadin page while transferring control from one jsp to another jsp Pin
TorstenH.7-Jul-11 19:33
TorstenH.7-Jul-11 19:33 
AnswerRe: Loadin page while transferring control from one jsp to another jsp Pin
Richard MacCutchan7-Jul-11 23:08
mveRichard MacCutchan7-Jul-11 23:08 
QuestionUnchecked casting? Pin
Neo101016-Jul-11 22:03
Neo101016-Jul-11 22:03 
Hello,

I would like to fully understand the concept of 'unchecked casting'.

I get an 'unchecked cast' warning when I try to do this:

<br />
List<Element> freq1;<br />
pfreq1 = XPath.newInstance("/values/val[@freq<10]");<br />
freq1 = (List<Element>) pfreq1.selectNodes(doc); //Unchecked cast warning<br />


What I am doing on line 3 is converting a List (pfreq1) to a List<Element> (freq1).
After googling, I have taken over the following 'cure', which worked:

<br />
private void makeValid(List li) {<br />
    freq1 = new ArrayList();<br />
    for (Object o : li) {<br />
        freq1.add((Element) o);<br />
    }<br />
}<br />
<br />
makeValid(pfreq1.selectNodes(doc));<br />


This works, but I do not know why. I do not know why the 'unchecked cast' warning disappears then.
I am explicitly converting each element of the generic List pfreq1 to an Element, thus making all elements in that generic List turn into real Element objects, which would make it a List<Element>. Now the compiler is sure that every object inside that List is now of type Element and thus can convert it safely to a List<Element>. That's how I see it.

However, what I would like to know is how and why unchecked casting works.

Thank you
AnswerRe: Unchecked casting? Pin
David Skelly6-Jul-11 22:30
David Skelly6-Jul-11 22:30 
QuestionNEED HELP REGARDING EMBEDDING THE CHAT SERVER I MADE ON MY WEBSITE TO SERVE AS LIVE CHAT. [modified] Pin
Member 80110535-Jul-11 23:16
Member 80110535-Jul-11 23:16 
AnswerRe: NEED HELP REGARDING EMBEDDING THE CHAT SERVER I MADE ON MY WEBSITE TO SERVE AS LIVE CHAT. Pin
Richard MacCutchan6-Jul-11 0:39
mveRichard MacCutchan6-Jul-11 0:39 
GeneralRe: NEED HELP REGARDING EMBEDDING THE CHAT SERVER I MADE ON MY WEBSITE TO SERVE AS LIVE CHAT. Pin
Member 80110536-Jul-11 2:57
Member 80110536-Jul-11 2:57 
GeneralRe: NEED HELP REGARDING EMBEDDING THE CHAT SERVER I MADE ON MY WEBSITE TO SERVE AS LIVE CHAT. Pin
Richard MacCutchan6-Jul-11 3:26
mveRichard MacCutchan6-Jul-11 3:26 
GeneralRe: NEED HELP REGARDING EMBEDDING THE CHAT SERVER I MADE ON MY WEBSITE TO SERVE AS LIVE CHAT. Pin
Member 80110536-Jul-11 3:31
Member 80110536-Jul-11 3:31 
AnswerRe: NEED HELP REGARDING EMBEDDING THE CHAT SERVER I MADE ON MY WEBSITE TO SERVE AS LIVE CHAT. Pin
TorstenH.6-Jul-11 0:50
TorstenH.6-Jul-11 0:50 
GeneralRe: NEED HELP REGARDING EMBEDDING THE CHAT SERVER I MADE ON MY WEBSITE TO SERVE AS LIVE CHAT. Pin
Member 80110536-Jul-11 2:58
Member 80110536-Jul-11 2:58 
Questiontry block problem in java.. Pin
gateway235-Jul-11 20:58
gateway235-Jul-11 20:58 
AnswerRe: try block problem in java.. Pin
Cedric Moonen5-Jul-11 21:39
Cedric Moonen5-Jul-11 21:39 
GeneralRe: try block problem in java.. Pin
gateway235-Jul-11 22:12
gateway235-Jul-11 22:12 
GeneralRe: try block problem in java.. Pin
Cedric Moonen5-Jul-11 22:35
Cedric Moonen5-Jul-11 22:35 
GeneralRe: try block problem in java.. Pin
David Skelly6-Jul-11 3:47
David Skelly6-Jul-11 3:47 
GeneralRe: try block problem in java.. Pin
TorstenH.6-Jul-11 3:52
TorstenH.6-Jul-11 3:52 
GeneralRe: try block problem in java.. Pin
David Skelly6-Jul-11 5:06
David Skelly6-Jul-11 5:06 
GeneralRe: try block problem in java.. Pin
Richard MacCutchan5-Jul-11 22:40
mveRichard MacCutchan5-Jul-11 22:40 
GeneralRe: try block problem in java.. Pin
gateway235-Jul-11 23:14
gateway235-Jul-11 23:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.