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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:54:44+00:00 2026-05-30T04:54:44+00:00

I am facing some difficulties while assigning the values in an array list. My

  • 0

I am facing some difficulties while assigning the values in an array list. My code is :

while (answer.hasMore()) {
  SearchResult rslt = (SearchResult)answer.next();
  Attributes attrs = rslt.getAttributes();
  System.out.println();
  if (attrs.get("department") != null && attrs.get("telephonenumber") != null) {
      System.out.println(attrs.get("department") + " " + attrs.get("name") + " " +
                         attrs.get("Description") + " " + attrs.get("mail") + " " +
                         attrs.get("telephonenumber")+
                         attrs.get("samaccountname") + attrs.get("samaccountname") );
}

I want to assign the values of attrs.get("department") + attrs.get("description")+ attrs.get("name")+attrs.get("mail") each one to an array list.

I tried to define at the beginning:

String[] name = new String[100];

and in the while loop i tried to read the name attribute, I tried to do:

name = attrs.get("name");

But it did not work. Can anyone help.

  • 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-30T04:54:45+00:00Added an answer on May 30, 2026 at 4:54 am

    You cannot directly assign strings to a array made of string “references”. You need to index it first. But it would be much better to actually use a list (and maybe convert it to an array later). Check out List and ArrayList in the Java documentation.

    As an example:

        Attributes attrs = new Attributes();
        List<String> attribValues = new ArrayList<String>();
        System.out.println();
        if (attrs.get("department") != null
                && attrs.get("telephonenumber") != null) {
            System.out
                    .println(attrs.get("department") + " " + attrs.get("name")
                            + " " + attrs.get("Description") + " "
                            + attrs.get("mail") + " "
                            + attrs.get("telephonenumber")
                            + attrs.get("samaccountname")
                            + attrs.get("samaccountname"));
            attribValues.add(attrs.get("department"));
            attribValues.add(attrs.get("telephonenumber"));
        }
    
        final String[] attribArray = attribValues.toArray(new  String[attribValues.size()]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been facing some serious issues while executing this particular JSP page. CODE
I am facing some issues while serializing objects (I am using JBoss Drools, and
I'm playing with Remote Actors but I'm facing some difficulties. Consider this server: object
I am facing some difficulties in getting my progress bar to retrieve its progress
This is a homework problem and I'm facing some difficulties to understand it. The
I'm facing some troubles still while learning, so I guess it tends to get
I'm facing some known solvable problem but struck out here. In my code, the
Our company is facing some difficulties with our CMS web application. This application was
The company I'm working for is facing some difficulties and our future is, let's
I am facing some problem while returning data from web services. I am using

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.