Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jul 2008

    variable variable names

    Hi guys,

    I am facing a problem in developing my application, scenario is like

    I am to declare and initiate a number of variables and I am not sure how many they can be, so I want to use variable names such as

    loop from 0 to n
    declare int VARIABLE_NAME plus Concatenate a number with its Name

    result will look like this


    Any suggestion, how it can be done ???

    Kashif Nawaz

  2. #2
    Regular Contributor
    Join Date
    Jul 2003

    Re: variable variable names

    Use an array

  3. #3
    Nokia Developer Champion
    Join Date
    Oct 2006
    Bangalore, India

    Re: variable variable names

    Well I really don't the answer to your question, but I have a sugesstion, see if it suits you...

    what I understand from your problem is that you get to know the number of variables needed only at run-time, and hence this is creating a problem...

    the most simple and effective solution i can think of is to use a vector or list instead, where vector[0] will act as variable0 and vector[1] will act as variable1 so on.

    will that solve your problem ?
    Amit Kankani
    Nokia Developer Champion

  4. #4
    Regular Contributor
    Join Date
    Jul 2008

    Re: variable variable names

    looking your scenario the best thing to implement is array; and be careful while working with J2ME, don't create variables unless it necessary as mobile phones have very little memory.


Similar Threads

  1. Singleton using TLS
    By abp_dk in forum Symbian
    Replies: 4
    Last Post: 2007-10-26, 15:07
  2. Replies: 4
    Last Post: 2007-05-31, 07:06
  3. Codewarrior's code completion - variable names
    By maju nokia in forum Symbian Tools & SDKs
    Replies: 7
    Last Post: 2007-05-08, 08:24
  4. problem with LISTBOX names....
    By anjihere in forum Symbian
    Replies: 4
    Last Post: 2006-12-27, 10:20
  5. Replies: 1
    Last Post: 2006-11-15, 07:03

Posting Permissions

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