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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:04:36+00:00 2026-05-24T07:04:36+00:00

so I have a list ‘Screens’ which contains custom class objects of type ‘screen’

  • 0

so I have a list ‘Screens’ which contains custom class objects of type ‘screen’ these are read from an XML file at run time. Also in the XML is a section called ‘path’ which contains strings, these are stored as further members of the ‘screen’ objects. What I’m trying to do is read the string value of path.left on the current screen and use to set the new value of currentScreen.
ie.
i know.. currentScreen.path.left = “park”
so i want.. currentScreen = currentChapter.Screens.park;

but it doesnt like it.. I tried the following but it wont find it in the list because the list is of ‘screen’s and not strings. Thanks.

String tmppath = currentScreen.path.left;
int index = currentChapter.Screens.indexOf(tmppath);
currentScreen = currentChapter.Screens.get(index);

the screen and path objects look like this:

public class Screen {
    public String id;
    public Integer backdrop;
    public Paths path;
    public List<Integer> areaMode = new ArrayList<Integer>();
    public List<String> areaName = new ArrayList<String>();
    public List<Region> areaArray = new ArrayList<Region>();

    public Screen(String mid, Integer backDrop, Paths mpath, List<Integer> mareaMode ,List<String> mareaName, List<Region> mareaArray) {
        id = mid;
        backdrop = backDrop;
        path = mpath;
        areaMode = mareaMode;
        areaName = mareaName;
        areaArray = mareaArray;
    }
}

public class Paths {
    public String left;
    public String right;
    public String top;
    public String bottom;

    public Paths(String mleft, String mright, String mtop, String mbottom) {
        left = mleft;
        right = mright;
        top = mtop;
        bottom = mbottom;
    }
}

Another problem i think I’m having is that I’m trying to find the ‘Screen’ instance using the ‘id’ string I’ve created inside of it.

  • 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-24T07:04:36+00:00Added an answer on May 24, 2026 at 7:04 am

    The indexOf() uses equals() operation on your object to determine what the position of your object in the list is.

    So, in your Screen object, the equals() method should use the path variable or some part of it for this to work. Without looking at that object, it would be hard to tell.

    @Be77amy — I’m going to make a wild assumption here that the path variable equates to the id of the Screen object. If that is true, then your problem is vastly simplified. You should implement a hashCode() and equals() method like so —

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        return result;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Screen other = (Screen) obj;
        if (id == null) {
            if (other.id != null)
                return false;
        } else if (!id.equals(other.id))
            return false;
        return true;
    }
    

    This will also enable you to lookup by id.

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

Sidebar

Related Questions

I have list of objects type Node ( items ). And Node class has
I have List objects which are shown like this: www.mysite.com/lists/123 Where 123 is the
I have List<Custom> where Custom is class Custom { public int id; public String
I have list view which contains 2 buttons and 2 textviews. I change the
I have List of User object, I just want to get User objects from
I have List List<MyType> , my type contains Age and RandomID Now I want
I have List<Car> cars = from c in myContext.Cars .Include(Wheels) .Include(Wheels.Nuts) orderby c.CarID These
I have list of objects that contain information about which classes static EventHandler should
I have List I want to sort Desc by Priority, which is int and
I have list of words. I type in a word misspelled. Can I query

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.