Why cast a String to a String?

后端 未结 3 935
误落风尘
误落风尘 2021-01-13 06:04

An article on the Oracle Java Community sites gives as an example (for a JPA Converter, but that\'s not relevant, I guess) the following method:

public Boole         


        
3条回答
  •  無奈伤痛
    2021-01-13 06:42

    Such cast is completely unnecessary. I can imagine that it was before

    public Boolean convertToEntityAttribute(Object y) {
        String val = (String) y;
        ...
    }
    

    But later the argument type was changed to String and the author simply forgot to remove the cast.

提交回复
热议问题