Results 1 to 3 of 3

Thread: Java Reflection

  1. #1
    Nazneen Ali is offline Senior Member
    Join Date
    Jul 2011
    Rep Power

    Default Java Reflection

    In this tutorial (Learn Java for Android Development: Reflection Basics) on Java Reflection, inspecting the 4th section of the article titled "Inspecting the Constructors Avalable within a Class", it is written,

    "To get just the constructors that are publicly available, use getConstructors(). However, if you want to inspect those methods specifically declared within the class, whether they are public or not, use getDeclaredConstructors() instead."

    What do they mean by constructors which are publicly available vs. the constructors which are declared within a class. Aren't all constructors declared within the class.

    Does it mean that constructors can be declared outside a class? I don't think so. Or does it mean that some constructors are not declared ( and are publicly available, may be default constructors) while others are declared, within the class of course.
    Don't forget to smile :-)

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: Java Reflection

    getConstructors == get all public constructors in current class.
    getDeclaredConstructors == get all constructors, regardless of visibility, in the current class.

    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Nazneen Ali is offline Senior Member
    Join Date
    Jul 2011
    Rep Power

    Default Re: Java Reflection

    Thank you very much!
    Don't forget to smile :-)

Similar Threads

  1. Java Reflection API
    By Nirmitha in forum Advanced Java
    Replies: 3
    Last Post: 09-20-2013, 09:13 AM
  2. how to use java.reflection with parameter(s)
    By newbiejava in forum New To Java
    Replies: 8
    Last Post: 08-25-2010, 10:21 AM
  3. Java reflection: find serializable classes in package
    By andrew222 in forum Advanced Java
    Replies: 2
    Last Post: 02-27-2010, 08:36 AM
  4. how to use reflection
    By sunilpatel28 in forum Advanced Java
    Replies: 1
    Last Post: 12-10-2008, 11:51 PM
  5. Array Reflection: Multi Array Reflection
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-23-2008, 09:08 PM

Tags for this Thread

Posting Permissions

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