Boolean.valueOf() produces NullPointerException sometimes

后端 未结 5 1512
名媛妹妹
名媛妹妹 2021-01-30 08:14

I have this code:

package tests;

import java.util.Hashtable;

public class Tests {

    public static void main(String[] args) {

        Hashtable

        
5条回答
  •  悲&欢浪女
    2021-01-30 08:24

    Since modifiedItems.get returns a Boolean (which is not castable to a String), the signature that would be used is Boolean.valueOf(boolean), where the Boolean is outboxed to a primitive boolean. Once null is returned there, the outboxing fails with a NullPointerException.

提交回复
热议问题