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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:45:25+00:00 2026-05-27T00:45:25+00:00

So I am writing short demo of iterators and linked lists: import java.awt.List; import

  • 0

So I am writing short demo of iterators and linked lists:

    import java.awt.List;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.LinkedList;


    class Marriage
{
    String person1;
    String person2;

    Marriage(String p1, String p2)
    {
        person1 = p1;
        person2 = p2;
    }
}

public class MyArrayList {
    Object[] container;
    int currSize;
    int numElements=0;

    public MyArrayList(int initialSize)
    {
        container = new Object[initialSize];
        currSize = initialSize;
    }
    public MyArrayList()
    {
        this(10);
    }
    public int size()
    {
        return numElements;
    }

    public void add(Object ob)
    {
        if (numElements >= currSize)
            resize();
        container[numElements++] = ob;
    }
    public Object get(int index)
    {
        if (index < 0 || index >= numElements)
            throw new IndexOutOfBoundsException("IndexOutOfBounds");
        return container[index];
    }
    private void resize()
    {
        Object[] newContainer = new Object[currSize*2];
        System.out.println("resize: "+ currSize);
        for (int i=0; i < currSize; i++)
            newContainer[i] = container[i];

        container = newContainer;
        currSize *= 2;
    }

    public static void main(String[] args)
    {
        LinkedList<Marriage> myCont2 = new LinkedList<Marriage>();


        myCont2.add(new Marriage("Gowen", "Geter"));
        myCont2.add(new Marriage("Holland", "Tunnell"));
        myCont2.add(new Marriage("Daffee", "Ducmann"));
        myCont2.add(new Marriage("Hay", "Saylors"));
        myCont2.add(new Marriage("Rump", "Orefice"));
        myCont2.add(new Marriage("Rump", "Hammer"));
        myCont2.add(new Marriage("True", "Belew"));
        myCont2.add(new Marriage("Hunting", "Hoar"));
        myCont2.add(new Marriage("Busch", "Hacker"));
        myCont2.add(new Marriage("Long", "Wiwi"));
        myCont2.add(new Marriage("Fedder", "Oats"));
        myCont2.add(new Marriage("Eggen", "Stake"));
        myCont2.add(new Marriage("de Armendi", "Back"));
        myCont2.add(new Marriage("Olah", "Sailer"));
        myCont2.add(new Marriage("Burns", "Toole"));
        myCont2.add(new Marriage("Gowen", "Geter"));

        myCont2.add(new Marriage("Mann", "Boobs"));
        myCont2.add(new Marriage("Cox", "Champ"));
        myCont2.add(new Marriage("Roller", "Moore"));
        myCont2.add(new Marriage("Achen", "Ball"));
        myCont2.add(new Marriage("Schauer", "Bush"));
        myCont2.add(new Marriage("Looney", "Ward"));
        myCont2.add(new Marriage("Poore", "Sapp"));
        myCont2.add(new Marriage("Neisser", "Ho"));
        myCont2.add(new Marriage("Best", "Lay"));
        myCont2.add(new Marriage("Hardy", "Harr"));
        myCont2.add(new Marriage("Crapp", "Beer"));

        myCont2.add(new Marriage("Traylor", "Hooker"));
        myCont2.add(new Marriage("Wang", "Holder"));
        myCont2.add(new Marriage("To", "Mann"));
        myCont2.add(new Marriage("Louse", "Donge"));
        myCont2.add(new Marriage("Fondel", "Longe"));

        Iterator<Marriage> iter2 = myCont2.iterator();
        while(iter2.hasNext())
        {
            System.out.println(iter2.next());
        }  

    } 


}

But when this prints I get the reference IDs and not the list. Any ideas?

Marriage@6bbc4459
Marriage@152b6651
Marriage@544a5ab2
Marriage@5d888759
Marriage@2e6e1408
Marriage@3ce53108
Marriage@6af62373
Marriage@459189e1
Marriage@55f33675
Marriage@527c6768
Marriage@65690726
Marriage@525483cd
Marriage@2a9931f5
Marriage@2f9ee1ac
Marriage@67f1fba0
Marriage@3fbefab0
Marriage@133c5982
Marriage@5f186fab
Marriage@3d4b7453
Marriage@24c21495
Marriage@41d5550d
Marriage@1cc2ea3f
Marriage@40a0dcd9
Marriage@1034bb5
Marriage@7f5f5897
Marriage@4cb162d5
Marriage@11cfb549
Marriage@5b86d4c1
Marriage@70f9f9d8
Marriage@2b820dda
Marriage@675b7986
Marriage@2687816d
  • 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-27T00:45:26+00:00Added an answer on May 27, 2026 at 12:45 am

    Marriage needs to override toString method properly.

    Something as follows:

    class Marriage {
        String person1;
        String person2;
    
        Marriage(String p1, String p2) {
            person1 = p1;
            person2 = p2;
        }
    
        @Override
        public String toString() {
            return person1 + " " + person2;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In short I am writing a class handler to handle to database integration of
I'm writing a short class to extract email addresses from documents. Here is my
I'm writing a short to a file, using the following code in Java :
I am writing a short script in python that will scan through a list
So, I am writing a short (and simple) regular expression, but I can think
Short of writing a function manually that translates a few known REFIID to names,
I am writing a function short getBits(short data, int p, int n) I have
Scala programmer should have known that this sort of writing : class Person{ var
So I am writing a Java code to represent a heap sort and to
I'm current writing a short bit of code that will compare an etag for

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.