Parentheses around data type?

前端 未结 5 999
醉梦人生
醉梦人生 2020-12-03 12:22

I am a beginning programmer and came across this in my textbook:

public boolean equals(DataElement otherElement)
{
    IntElement temp = (IntElement) otherEl         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 13:07

    jmein is correct, it tells the compiler/interpreter to turn the one variable type into another. In reality it is just telling the processor to treat it as another type. In C this is a blessing and a curse, in java, what looks like you are writing, you MUST cast the variable to treat it differently.

提交回复
热议问题