Parentheses around data type?

前端 未结 5 1003
醉梦人生
醉梦人生 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:03

    The purpose of (IntElement) after temp is performing a type conversion, more technically, a cast, where you're saying that otherElement, which is a parameter of type DataElement, should be taken as an object of the more concrete type IntElement.

提交回复
热议问题