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 7589089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:04:48+00:00 2026-05-30T20:04:48+00:00

I have a java form in which i have declared different variables of type

  • 0

I have a java form in which i have declared different variables of type string , and few variables of type string array and few are collections.
Using getdeclaredfileds of reflection api , i am getting every field of class in my field array variable.
But i want to separate the string variables into one common array.
array strings into other array and collection fields into other one.

eg: – String abc;
String def;
String[] lmn;
String[] opq;
Collection mno;

  • 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-30T20:04:49+00:00Added an answer on May 30, 2026 at 8:04 pm

    Define a utility method:

    public static Map<Class<?>, List<Field>> getFieldsByType(Field[] fields) {
      Map<Class<?>, List<Field>> result = new HashMap<Class<?>, List<Field>>();
      for (Field field:fields) {
        List<Field> fieldList = result.get(field.getType());
        if (fieldList == null) {
          fieldList = new ArrayList<Field>();
          result.put(field.getType(), fieldList);
        }
        fieldList.add(field);
      }
      return result;
    }
    

    It separates the fields by type and stores them in a map.

    Example usage:

    Map<Class<?>, List<Field>> map = getFieldsByType(MyClass.class.getDeclaredFields());
    List<Field> stringTypeMembers = map.get(String.class);
    

    Now stringTypeMember contains all class members (fields) that are of type String.

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

Sidebar

Related Questions

I have a html form which is populated using a java for loop. And
I created a form using Swing in Java. In the form I have used
I have a java script code which will set some values in a form
Possible Duplicate: how to convert java string to Date object I have a form
I have one .java file in which I have a form for user registration
I have a Java String which is actually an SQL script. CREATE OR REPLACE
I have a JSP form which is made of <input type=file/> tag alone for
I have this java servlet that grabs information from a form, I need to
Once I have programmed GUI with Java and have used Form Layouts. Form layout
I have created a fairly substantial Java GUI application with many form windows where

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.