Can't convert type PortfolioTrade[] as List<String>

i have got the following error.somebody please help me with this

Hi, you should not share your code on the forum.

As for your issue, you need to return a List object, but you are returning a Portfolio Trade array. Either modify the method return type, or convert your array to List and then return it.

Your portfoliotrade array sounds good.
But try something else with list of strings
Try some sort of loop to extract data from that array

you mean should i loop over that array of stocks and add them list and return it

You are always one step away from trying.
Remember one thing there are different functions in the POJO class to get the values.
Try using them to extract the required output.

Is your problem solved?

No.not yet.i tried by including class… but I didn’t get.can’t we print the list and check what we are getting…I tried running java file but it’s showing import errors.

I suppose you have made a array of type String , right?
But what the code requires you to make is… a List<String> not an array of String… make sure you doing that right

solved!! thanks everyone

though i have got info list my build ./gradlew build is getting failed. i don’t know what’s the problem.

can you share the error you are getting?

in the todos it was said there will be some unused imports…should we comment them?

this is specified in to do checkstyles you have to follow a specific format in code in order to pass build

okay… so you are getting checksyle error…

like check the second error message
it says for is not followed by whitespace… then instead of doing


you have to do

for (condition) {

notice the gaps!

There are many similar errors relating to formatting the code correctly :slight_smile:

this is the error i’m getting now.

@jyotirmoy-paul can you please look through it once .i did’nt understand why is there an exception

solved!! thanks @jyotirmoy-paul

yes, you see task: ‘qmoney:checkstyleMain’ is failing
That does mean you have nor formatted your code properly as expected.

Please check the error you are getting, like

  1. preceed - and < and { with whitespace - as in line 53
  2. use proper indentation level, like might be 4 is required, but you have given 5
  3. provide gaps in the for statement - as in line 53
  4. make sure the length of anyline is not longer than 100 - as in line 72,113
  5. there must be a space above and below the import statement - as in line 2

Checkstyle just checks for code formatting, you just need to take care of how well and clear your code is written.

Hope this helps

Ohh! I see, great :slight_smile: