This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

converting ArrayList to 2d array in Java -- Syntax error, insert "... VariableDeclaratorId"....  RSS feed

 
Frank Poupard
Ranch Hand
Posts: 65
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I'm trying in the following code to convert an ArrayList to a 2d array. But as said in the title, I get the following error Syntax error, insert "... VariableDeclaratorId" to complete FormalParameterList" line 15, which I don't understand (even if I made some research). Any idea ? Thanks in advance


 
Dave Tolls
Rancher
Posts: 2913
35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your 'list' parameter in listToArray has no type associated with it:
 
Frank Poupard
Ranch Hand
Posts: 65
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, it saved me time !
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frank Poupard wrote:I'm trying in the following code to convert an ArrayList to a 2d array.

I think Dave's covered this error, but you do realise that your listToArray() method will throw an Exception if you ever have a String (or CharSequence) that is longer than the size of your List.

And even if you don't, you'll probably be wasting a lot of space.

Have a think about creating a "jagged" array instead.

HIH

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!