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

The Archive Base Latest Questions

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

I am sure this is a very easy question for many, but I am

  • 0

I am sure this is a very easy question for many, but I am struggling with it. I am trying to get a value from the following constructor and place it in a vector.

Each time I add the object to the vector though, the value that is placed inside the vector is null. How can I get the number to be the value that is placed into the vector?

The CInteger class:

public class CInteger  
{
    private int i;
    CInteger(int ii)
    {
        i = ii;
    }
}

And in my A1 class, the constructor and my attempt at getting the value:

    Object enqueue(Object o) 
    {
        CInteger ci = new CInteger(88);
        Object d = ??
        add(tailIndex, d);// add the item at the tail
    }

Thank you all for any insight and help, I am still learning.

EDIT: SOLVED

CInteger class:

public class CInteger implements Cloneable // Cloneable Integer 
{
    int i;
     CInteger(int ii)
    {
        this.i = ii;
    }

public int getValue()
    {
        return i;
    }

}

Both enqueue methods:

public void enqueue(CInteger i)  // enqueue() for the CInteger
{
    add(tailIndex, new Integer(i.getValue())); get int value and cast to Int object
}
public void enqueue(Date d)  // enqueue() for the Date object
{
    add(tailIndex, d);
}

Thank you very much everyone. 😀

  • 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-20T20:33:05+00:00Added an answer on May 20, 2026 at 8:33 pm

    You can simply overload the enqueue class to take both Dates and Integers. In either case, it sounds like you need a method getValue() in CInteger that lets you access the int value.

    public class CInteger
    {
        //constructors, data
    
        public void getValue()
        {
            return i;
        }
    }
    

    and then you can have two enqueue() methods in your other class:

    public void enqueue(Date d)
    {
        add(tailIndex, d);
    }
    
    public void enqueue(CInteger i)
    {
        add(tailIndex, new Integer(i.getValue()); //access the int value and cast to Integer object
    }
    

    And Java will know which one you are calling automatically based on the parameters.

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

Sidebar

Related Questions

Im sure this is a very simple and easy to answer question but I've
For sure this question is very easy, but I just cannot figure this out.
I am sure that for most this is a very easy question. But I
I'm sure this is a very simple question, but embarrassed to say I can't
This is a very rudimentary question, but I am sure someone out there knows
This is probably a very easy question to answer, but for the life of
I'm sure this question will be easy for you lot... :) I'm simply trying
This is a really easy question I'm sure but I'd appreciate the help. :)
I'm sure this is a very obvious question but I'm not getting anywhere with
This is supposedly a very easy question, but I just can't seem to find

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.