unchecked or unsafe operation error

后端 未结 1 1783
情话喂你
情话喂你 2021-01-17 01:33

I have made this program for finding the Longest progressive sequence. Though it runs but I am getting the following compile time error: Sequence.java uses unchecked or unsa

相关标签:
1条回答
  • 2021-01-17 01:44

    TreeSet is a generic Class. You need to give it a type. It looks like you're adding ints into it, so the correct declaration would be

    TreeSet<Integer> ans = new TreeSet<>();
    

    or, in pre Java7 versions,

    TreeSet<Integer> ans = new TreeSet<Integer>();
    
    0 讨论(0)
提交回复
热议问题