Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextUtils.join on integer ArrayList

I have 3 booleans which indicate if an int should be added to a list or not, then I would like to use TextUtils.join() on this list.

How should I proceed ?

ArrayList<Integer> types = new ArrayList<Integer>();

if (m_bWithA) {
   types.add(this.TYPE_A); //TYPE_A is an int
}
if (m_bWithB) {
   types.add(this.TYPE_B); 
}
if (m_bWithC) {
   types.add(this.TYPE_C); 
}

TextUtils.join("|", types);

But it says that we can only use TextUtils.join() on Object[].

Should I use another function or a different type of object ?

like image 952
user1668345 Avatar asked Jul 02 '26 06:07

user1668345


1 Answers

use TextUtils.join(types.toArray())

like image 55
AlexR Avatar answered Jul 04 '26 20:07

AlexR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!