| Author |
How to group?
|
Jay Orsaw
Ranch Hand
Joined: Jun 14, 2011
Posts: 354
|
|
Kind of a vague question, but didn't know how to ask it. Basically I have a this set of code, I posted the first 2 of 6, and I wanted to know how I would be able to reduce this into 1?
basically the code is EXACTLY the same besides f1,f2,f3,....,f6.
I figured I might be able to do something like f(n) or something like that, but I don't know.
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12907
|
|
Instead of having six variables f1, f2, f3, ..., f6 you could create an array.
Have a look at: The Java Tutorials - Arrays.
For example:
Access the six elements of the array as f[0], f[1], f[2], ..., f[5]. Ofcourse you can use a variable to index into the array:
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
 |
|
|
subject: How to group?
|
|
|