Results 1 to 3 of 3
- 07-18-2007, 11:39 AM #1
Member
- Join Date
- Jul 2007
- Posts
- 2
- Rep Power
- 0
building file and variable names from variables
Hi,
I'm fairly new to java, but need some help with converting what is an easy action in scripting languages but usually not so easy in programming languages. In scripting I would do the following (in pseudo-codish):
for i=0 , i<10 , i++
print "hello world no. $i"
open "filename$i"
readin "filename$i"
var.$i = var.$i + var.$(i-1)
done
Note the use of the $i. How can I do this in Java? I can do it in C and Fortran, but can't seem to find a reference on how to do it in Java. (The specific commands I used above are an example only)
Thanks for your help.
- 07-18-2007, 12:21 PM #2
As far as i see, you are interested in concatenating a string with an integer. Lets assume that you have a string variable str and an int variable i. You will need to create an Integer object from your int primitive value and concatanete as follows:
Java Code:String combined = str + (new Integer(i).toString());
- 07-18-2007, 04:47 PM #3
Member
- Join Date
- Jul 2007
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
variables in hibernate.cfg.xml file
By bbq in forum JDBCReplies: 4Last Post: 07-05-2008, 05:47 AM -
Adding file names(Help!!)
By Gambit17 in forum New To JavaReplies: 4Last Post: 11-09-2007, 07:26 AM -
variable access from another file
By riadmazloum in forum AWT / SwingReplies: 1Last Post: 08-06-2007, 07:13 PM -
how can I get the names of variables in runtime?
By tommy in forum New To JavaReplies: 1Last Post: 07-27-2007, 10:37 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks