Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6361611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:47:59+00:00 2026-05-24T23:47:59+00:00

In the book Thinking in Java there is an example of how to get

  • 0

In the book “Thinking in Java” there is an example of how to get information for a bean via Reflection/Introspection.

BeanInfo bi = Introspector.getBeanInfo(Car.class, Object.class);
for (PropertyDescriptor d: bi.getPropertyDescriptors()) {
  Class<?> p = d.getPropertyType();
  if (p == null) continue;
  [...]
}

In line 4 of that sample above there is a check if the PropertyType is null. When and under what circumstances does that happen? Can you give an example?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:48:00+00:00Added an answer on May 24, 2026 at 11:48 pm

    The Javadoc for the getPropertyType method of the PropertyDescriptor class states:

    The result may be “null” if this is an indexed property that does not
    support non-indexed access.

    Indexed properties are those that are backed by an array of values. In addition to the standard JavaBean accessor methods, indexed properties may also have methods to get/set individual elements in the array, by specifying an index. The JavaBean, may therefore, have the indexed getters and setters:

    public PropertyElement getPropertyName(int index)
    public void setPropertyName(int index, PropertyElement element)
    

    in addition the standard getter and setter for non-indexed access:

    public PropertyElement[] getPropertyName()
    public void setPropertyName(PropertyElement element[])
    

    Going by the Javadoc description, if you omit the non-indexed accessors, you can obtain a return value of null for the property type of the property descriptor.

    So, if you have a JavaBean of the following variety, you could get a null return value:

    class ExampleBean
    {
    
        ExampleBean()
        {
            this.elements = new String[10];
        }
    
        private String[] elements;
    
        // standard getters and setters for non-indexed access. Comment the lines in the double curly brackets, to have getPropertyType return null.
        // {{ 
        public String[] getElements()
        {
             return elements;
        }
    
        public void setElements(String[] elements)
        {
             this.elements = elements;
        }
        // }}
    
        // indexed getters and setters
        public String getElements(int index) {
            return this.elements[index];
        }
    
        public void setElements(int index, String[] elements)
        {
             this.elements[index] = elements;
        }
    
    }
    

    Note, while that you can implement the indexed property accessors alone, it is not recommended to do so, as the standard accessors are used to read and write values, if you happen to use the getReadMethod and getWriteMethod methods of the PropertyDescriptor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi i've been trying to install the library on Thinking in Java book 4th
I'm wondering what a good book to read describing how ASP.NET works. I'm thinking
i am teaching myself java and i work through the exercises in Thinking in
The Subversion SVN book says : ...Another way of thinking about this pattern is
There are a few hundred of book records in the database and each record
Reading through Thinking in Java i stuck in ex:6 of Inner Classes chapter. Exercise
Reading the book I found the following: The way of thinking when you model
There was a passing comment in a book of mine about people inputting commas
I'm almost finished with the book Head First Java. The reason I'm studying this
I am reading the book Thinking in C++ (2nd edition Vol 1) and i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.