Results 1 to 2 of 2
  1. #1
    JavaForums's Avatar
    JavaForums is offline Administrator
    Join Date
    Dec 2006
    Rep Power

    Default Reflection example - accessing private data

    If you think that you cannot access private data members of a class from some other class, then think again. With Reflection, this is possible.

  2. #2
    alchemist is offline Member
    Join Date
    Sep 2009
    Rep Power


    Yes you can see private class variables you need use: myobject.getClass().getDeclaredFields()



    Using getDeclaredFields reveals all class vars, getFields() only reveals publicly accessible vars

    Here's a good example of these call in use:

Similar Threads

  1. [SOLVED] Accessing private constructor
    By piyu.sha in forum New To Java
    Replies: 2
    Last Post: 10-06-2008, 05:45 AM
  2. Axis Client accessing data on .Net webservice
    By cfacile666 in forum Web Frameworks
    Replies: 3
    Last Post: 09-02-2008, 11:35 AM
  3. simple question about private data
    By littleBean in forum New To Java
    Replies: 12
    Last Post: 07-02-2008, 04:09 PM
  4. Accessing Data from a .txt file
    By Oasis13 in forum New To Java
    Replies: 5
    Last Post: 02-01-2008, 01:16 AM
  5. Packaging and accessing data files
    By todd in forum Advanced Java
    Replies: 1
    Last Post: 08-01-2007, 12:27 AM

Posting Permissions

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