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

  • Home
  • SEARCH
  • 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 557449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:01:38+00:00 2026-05-13T12:01:38+00:00

I have this class: public class User { public User(String nickname, String ipAddress) {

  • 0

I have this class:

public class User {


    public User(String nickname, String ipAddress) {

        nickname = nickname.toLowerCase();
        System.out.println(nickname + " " + ipAddress);
    }
}

And another class that creates an array containing User objects.

class UserMananger {

    static User user;
    static User user2;
    static User user3;

    static ArrayList allTheUsers;

       public void UserManager() {

           allTheUsers = new ArrayList();

           user = new User("Slavisha", "123.34.34.34");
           user2 = new User("Zare", "123.34.34.34");
           user3 = new User("Smor", "123.34.34.34");

           allTheUsers.add(user);
           allTheUsers.add(user2);
           allTheUsers.add(user3);


       }
}

What I want to do is to call a main method that will give me all elements from the list that are type User in format: “nickname ipAddress”

public static void main(String args[]) {

        System.out.println(allTheUsers.get(0));
    }

For example, this main method should give me something like:
Slavisha 123.34.34.34
but it doesn’t. What seems to be the problem?

  • 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-13T12:01:39+00:00Added an answer on May 13, 2026 at 12:01 pm

    First problem: you haven’t overridden toString() in User. For example:

    @Override
    public String toString() {
        return nickname + " " + ipAddress;
    }
    

    Second problem: each time an instance of UserManager is created, you’re changing the values of your static variables… but you’re not doing anything unless an instance of UserManager is created. One option is to change the constructor of UserManager into a static initializer:

    static {
        // Initialize the static variables here
    }
    

    Third problem: you haven’t shown us where your main method is, so we don’t know whether it has access to allTheUsers.

    Fourth problem: “it doesn’t” isn’t a good description of your problem. Always say what appears to be happening: are you getting an exception? Is it just printing the wrong thing?

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

Sidebar

Ask A Question

Stats

  • Questions 314k
  • Answers 314k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You'll lose duplicates if you actually wanted them. If this… May 13, 2026 at 10:59 pm
  • Editorial Team
    Editorial Team added an answer Had a similar problem in Tomcat/JSP, don't know about PHP.… May 13, 2026 at 10:59 pm
  • Editorial Team
    Editorial Team added an answer Can you confirm that there is a make.exe in C:\MinGW\bin?… May 13, 2026 at 10:59 pm

Related Questions

I have this domain hierarchy: User -> EntityWithAuditDate -> Entity Here is the domain:
I'm using S#arpArchitecture (ASP.NET MVC and Fluent NHibernate). I have an entity as follows:
Say, You have an application which lists down users in your application. Ideally, if
I have the following piece of code in my DataModel.cs class: public User ValidateUser(string
Yo i have the following nhibernate class: public class User { public virtual int

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.