print Bit Set List - Java java.util

Java examples for java.util:BitSet

Description

print Bit Set List

Demo Code


//package com.java2s;

import java.util.BitSet;

import java.util.List;

public class Main {


    public static String printBitSetList(List<BitSet> l) {
        if (l == null)
            return "null";
        StringBuilder sb = new StringBuilder("{");
        for (BitSet bs : l) {
            sb.append('{');
            for (int b = bs.nextSetBit(0); bs.nextSetBit(b + 1) != -1; b = bs
                    .nextSetBit(b + 1))//from   ww  w.  j a v  a 2s  . c  o m
                sb.append(b).append(',');
            sb.replace(sb.length() - 1, sb.length(), "}");
        }
        sb.append('}');
        return sb.toString();
    }
}

Related Tutorials