This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
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


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: 3020
    
  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: 19651
    
  43

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: 19651
    
  43

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assigning string variable inside for loop