Why cast a String to a String?

后端 未结 3 889
误落风尘
误落风尘 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:54

    This redundant casting is useless.

    Current code can be simplify to

    public Boolean convertToEntityAttribute(String y) {
        return "Y".equals(y);
    }
    

提交回复
热议问题