Why string array can't be added to backendless user?

I have same problem…
My code

Object[] objects = (Object[]) Backendless.UserService.CurrentUser().getProperty( "channels" );
Channel[] channelsArray;

if( objects != null && objects.length > 0 ){
    channelsArray = (Channel[]) objects;
} else {
    channelsArray = new Channel[0];
}

getting this error:

java.util.LinkedList cannot be cast to java.lang.Object[]

Exactly which line of code produces the error?

Object[] objects = (Object[]) Backendless.UserService.CurrentUser().getProperty( “channels” );

And i’m using LinkedList to put some data into channels property

Well, the error says linkedlist cannot be cast to object[], so don’t. Change object[] to linkedlist or list or collection…

Yeah, but sometimes it’s Object[] and sometimes LinkedList and other time Channel[].

java.lang.ClassCastException: pl.mythiclands.ahmex.igramyMob.entity.Channel[] cannot be cast to java.util.LinkedList

And my code after change is

private static List<String> getUserChannelsFromList(){
    LinkedList<Channel> objects = (LinkedList) Backendless.UserService.CurrentUser().getProperty( "channels" );

    if( objects == null || objects.size() == 0 )
        objects = new LinkedList<>();
    return Helper.convertChannelListToStringList(objects);
}

Whenever BackendlessUser is loaded from the server, it will contain an array of objects. In the case when it is LinkedList, it must be a value you put into BackendlessUser (meaning it is an object initialized on the client-side).

So it’s gonna be array of LinkedLists?

Whatever you put into a property in BackendlessUser, it will contain and return that value UNTIL you save the object. After it is saved AND if you use the object returned from the server, it will always contain an array of objects.

OH!
That’s make sense for me now. Thank you a lot!!