开发者

error in netbeans about join method

   ArrayList<T> set=new ArrayList<T>();


   for(int i=0;i<list.size();i++)
       {
       for(int j=0;j<t.size();j++)
       {
           if(!list.get(i).equals(t.get(i)));------------>netbeans say t.get(i) is error
               set.add((T) t.list.get(j));
       }

i should write a join method to join two set.What should I write inst开发者_高级运维ead of t.get(i)????


And what about list.size()? Both list and t are undefined (at least in the code snippet you have sent).

Please try to read what does compiler say you. I believe that error message will explain you where the problem is. If you still do not understand please supply bigger code snippet.


If you want to work on a set data structure, start using a set.

Set set = new HashSet();

The semantics of a "Set" already imply that there are no duplicates in it. To have a union, simply add all new elements.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜