How to return a specific element of an array?

前端 未结 4 1820
臣服心动
臣服心动 2020-12-20 01:49

I want to return odd numbers of an array yet Eclipse doesn\'t seem to accept my return array[i]; code. I think it requires returning a whole array since I set a

4条回答
  •  暖寄归人
    2020-12-20 02:26

    (Edited.) There are two reasons why it doesn't compile: You're missing a semi-colon at the end of this statement:

    array3[i]=e1
    

    Also the findOut method doesn't return any value if the array length is 0. Adding a return 0; at the end of the method will make it compile. I've no idea if that will make it do what you want though, as I've no idea what you want it to do.

提交回复
热议问题