Why do I have NullPointerException in my sort implementation?

前端 未结 2 431
梦谈多话
梦谈多话 2021-01-29 07:21

I\'m working on my assignment and I am suppose to create a sort method for my array. However, I\'m getting a null pointer error in my sort method and I\'m not sure why. This is

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-29 07:53

    See if any elements of setArray are null. Arrays.sort() requires that each element of the array being sorted has to be non-null: "All elements in the array must implement the Comparable interface."

提交回复
热议问题