Added function to print a list
This commit is contained in:
@@ -968,4 +968,16 @@ public class Algorithms{
|
||||
//Conver the number to binary string
|
||||
return num.toString(2);
|
||||
}
|
||||
//Print a list
|
||||
public static <T> String printList(ArrayList<T> list){
|
||||
StringBuilder listString = new StringBuilder("[");
|
||||
for(int cnt = 0;cnt < list.size();++cnt){
|
||||
listString.append(list.get(cnt));
|
||||
if(cnt < list.size() - 1){
|
||||
listString.append(", ");
|
||||
}
|
||||
}
|
||||
listString.append("]");
|
||||
return listString.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user