Java: How to write a `zip` function? What should be the return type?

后端 未结 5 1453
攒了一身酷
攒了一身酷 2020-12-06 02:48

What should be the return type of a zip function? (zip as in most other languages, e.g. read here)

I thought about some Pair-type but that

5条回答
  •  醉酒成梦
    2020-12-06 03:45

    Here is a start.

    public class Pair
    {
        private T1 first;
        private T2 second;
    
        public Pair(T1 first, T2 second)
        {
            this.first = first;
            this.second = second;
        }
    
        public T1 getFirst()
        {
            return first;
        }
    
        public T2 getSecond()
        {
            return second;
        }
    }
    

提交回复
热议问题