List Variables & Type

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave

    List Variables & Type

    Is it possible to extract all the used variables (&type) from a piece of
    sourcecode, rather than doing it manually?

    Cheers,
    Dave


  • mhandis

    #2
    Re: List Variables & Type

    It is not clear what you mean exactly by "extract all the used variables
    (&type)".

    Dave wrote:[color=blue]
    > Is it possible to extract all the used variables (&type) from a piece of
    > sourcecode, rather than doing it manually?
    >
    > Cheers,
    > Dave
    >
    >[/color]

    Comment

    • nos

      #3
      Re: List Variables & Type


      "Dave" <bigdavepotnood le*SPAM*hotmail .com> wrote in message
      news:3ffd839c$0 $13348$cc9e4d1f @news-text.dial.pipex .com...[color=blue]
      > Is it possible to extract all the used variables (&type) from a piece of
      > sourcecode, rather than doing it manually?
      >
      > Cheers,
      > Dave
      >[/color]
      Suppose your class is Plot1();
      You can use reflection class methods.
      The following (needs to be tested)
      fragment prints out all fields. Also
      look at "getFields( )"
      It gives you something like this:
      private static AlignRight Plot1.ar
      for each field.
      ----

      Plot1 p1 = new Plot1();
      Class className = p1.getClass();

      Field[] fields = className.getDe claredFields();

      for (int i = 0; i < fields.length; i++) {
      System.out.prin tln(fields[i]);
      }


      Comment

      Working...