Results 1 to 6 of 6
  1. #1
    dutchgold92 is offline Member
    Join Date
    Feb 2011
    Posts
    8
    Rep Power
    0

    Default Processing variables

    Greetings, I'm wondering if there's any way to process variables similarly to arrays in this manner?

    Java Code:
    int var1 = 0, var2 = 0, var3 = 0;
    
    for (int x = 0; x < 4; x++)
         var(x) = 1;
    Looking for a solution to output objects and we haven't covered vectors yet.

  2. #2
    Iron Lion is offline Senior Member
    Join Date
    Nov 2010
    Posts
    210
    Rep Power
    4

    Default

    What you're looking for is arrays.

  3. #3
    dutchgold92 is offline Member
    Join Date
    Feb 2011
    Posts
    8
    Rep Power
    0

    Default

    Quote Originally Posted by Iron Lion View Post
    What you're looking for is arrays.
    Quote Originally Posted by dutchgold92 View Post
    Greetings, I'm wondering if there's any way to process variables similarly to arrays in this manner?
    I need to process objects so I don't think arrays really work here.

  4. #4
    Iron Lion is offline Senior Member
    Join Date
    Nov 2010
    Posts
    210
    Rep Power
    4

    Default

    Oops, sorry.

    Nope, there's no way to do what you're describing. Identifiers such as 'var1' don't exist during runtime, so you can't manipulate them with your program. There's nothing to stop you having an array of objects, though, or some other collection.

  5. #5
    Solarsonic is offline Senior Member
    Join Date
    Mar 2011
    Posts
    261
    Rep Power
    4

    Default

    Make object arrays.

    Java Code:
    ClassName[] objectArray = new ClassName[20];
    Last edited by Solarsonic; 03-31-2011 at 11:53 PM.

  6. #6
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,948
    Rep Power
    19

    Default

    Using a Map of some sort possibly?
    We don't really have enough information on what you are trying to achieve to say.

Similar Threads

  1. image processing
    By rohankapoor in forum New To Java
    Replies: 4
    Last Post: 03-01-2011, 06:35 AM
  2. Signal processing API.
    By ivanloes in forum New To Java
    Replies: 2
    Last Post: 12-18-2010, 10:22 AM
  3. Processing help
    By menez in forum Java Applets
    Replies: 3
    Last Post: 02-23-2010, 02:13 AM
  4. What are Instance variables and static variables?
    By sandeshforu in forum New To Java
    Replies: 3
    Last Post: 09-09-2009, 05:48 PM
  5. list processing
    By kazitula in forum Java Applets
    Replies: 1
    Last Post: 01-22-2008, 09:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •