How to print list separated by comma in Java

import java.util.ArrayList;
import java.util.stream.Collectors;

public class CommaDelimeter {
    public static void main(String[] args) {
        ArrayList<Integer> collectNums = new ArrayList<Integer>();
        collectNums.add(2);
        collectNums.add(9);
        collectNums.add(12);

        String joined = collectNums.stream()
                .map(Object::toString)
                .collect(Collectors.joining(", "));

        System.out.println(joined);
    }
}

How to generate all subsets of power set using bitwise mask in C#

namespace SubsetsOfSet
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    class SubsetsOfSet
    {
        static void Main()
        {
            int[] nums = { 0, 1, 2 };
            string[] fruits = {"apple", "peach", "starwberry"};

            int b = nums.Length;
            int n = (int)Math.Pow(2, b);

            for (int num = 0; num < n; num++)
            {
                var subSet = new List<int>();
                for (int bit = 0; bit <= b; bit++)
                {
                    if ((num >> bit & 1) == 1)
                    {
                        subSet.Add(nums[bit]);
                    }
                }

                Console.WriteLine("{{{0}}}", string.Join(", ", subSet.Select(i => fruits[i])));
            }
        }
    }
}