jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes Assigning string variable inside for loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Assigning string variable inside for loop" Watch "Assigning string variable inside for loop" New topic
Author

Assigning string variable inside for loop

Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
Hi,

I have initially decalred string variables as follow:

And trying to assign the data inside a for loop as below:



But I always get error inside for loop (line 3 and 4).
Thanks in advance.

>
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3011
    
  10
Well, what does the error message say?
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
Hi Simon,

error says "can not find symbol lib"
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18748
    
  40

Gopu Akraju wrote:
error says "can not find symbol lib"


Well... did you declare a variable name "lib"?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
Hi Henry,
I have declared them as in line 1.


I want to loop these variables without writing like



I don't get any errors in the above lines. Where as I am trying do this inside a for loop.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18748
    
  40

Gopu Akraju wrote:
I have declared them as in line 1.



I think you need to brush up on array variables. Declaring eight different variables whose name happen to start with "lib", is not the same as declaring a "lib" array variable.

Henry
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
Thanks. Henry. I have changed my code as suggested.
 
Don't get me started about those stupid light bulbs.
 
subject: Assigning string variable inside for loop