Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

String Array Question  RSS feed

 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The line in bold (i.e. repCriteria[lineCnt] =) gives me errors. Can anyone tell me whats wrong with this line? Thanks.

Rob
 
Hussam Bamatraf
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that you didn't initialize repCriteria array before using it:

You should initialize the array:
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66204
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on JSP.

This post has been moved to a more appropriate forum.
 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do I have to declare the size of the String array then? Is there no way to leave it open or set it to a small size and adjust if need be (i.e. equivalent to redim in VB)?
I tried to stay away from setting the size but if I have to I will. Thanks.

Rob
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
all Arrays have to have their size declared when you create them. There are other options you could use that let you re-size them. Check the API for something that might work... like an ArrayList.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rob Hunter:
Do I have to declare the size of the String array then? Is there no way to leave it open or set it to a small size and adjust if need be (i.e. equivalent to redim in VB)? ...

In Java, the size of the array must be set when the array is created, and it cannot be resized. (For a "resizable array," use an ArrayList.)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!