Length of list,select item index block in extensions

length of list.JPG
how to use this block in extension code i get a YailList colors from users how to get length of it,
and also how to
use this block in extension code
listt is the colors list i get index is 3
so how to use

Please explain properly.

i get a list from user where user put colours in the list and give me now how can get length of the input or length of list,how can i select item 3 of the colour list provided
the user give me this list i get it by the code

@SimpleFunction(description = "")
    public void bgset(YailList colors) {

now how to get length of list,get item 3(which is yellow)

@SimpleFunction(description = "")
  public Object bgset(YailList colors) {
  return (colors[0]);

The 0 number is the index number which start from 0.

This is select list item. :smile:

For length use-

@SimpleFunction(description = "")
  public int bgset(YailList colors) {
  return (colors.length);

More information-

ok i will try

dint work array required but yail list found is my compile error but
converting to array works

int[] array = new int[colors.size()];
     int index = 0;
     for(String e : colors.toStringArray()) {
         array[index] = Integer.parseInt(e);
int i;
     int size = array.length;

thanks i got help from this word

and error which says i need array

1 Like

What error did you get? @Alpha2020's code is correct.

i don't know the specific error but it said

could not be used in this method

only array can work like

where i converted list to array using

Try to use list.get(index)

That is what is said :sweat_smile: :joy:


If you want to get size of the list use:-


If you want to select list item with index then use this:-

listname.get( index );

Hope this will help

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.