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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:48:22+00:00 2026-06-16T01:48:22+00:00

So for my local data structure I have the following DataStructure ds = new

  • 0

So for my local data structure I have the following

DataStructure ds = new DataStructure();

    //Examples to put in the Data Structure "ds"
    ds.menu_item.put("Pizza", new DescItems("A Pizza",2.50,4));
    ds.menu_item.put("Hot Dog", new DescItems("A yummy hot dog",3.50, 3));
    ds.menu_item.put("Corn Dog", new DescItems("A corny dog",3.00));
    ds.menu_item.put("Unknown Dish", new DescItems(3.25));

The DataStructure class has a LinkedHashMap implementation such that

LinkedHashMap<String, DescItems> menu_item = new LinkedHashMap<String, DescItems>();

And finally the DescItems class is

public final String itemDescription;
public final double itemPrice;
public final double itemRating;

public DescItems(String itemDescription, double itemPrice, double itemRating){
    this.itemDescription = itemDescription;
    this.itemPrice = itemPrice;
    this.itemRating = itemRating;
}

There are other constructors to account for no itemDescription and/or itemRating

I’m trying to apply a method to check to see if a value has itemRating other than 0 (0 indicating no rating)

But specifically I came across this problem:

DescItems getC1 = (DescItems)ds.menu_item.get("Pizza");
    System.out.println(getC1.toString());

Only prints out reference information like DescItems@142D091

What should I do to get a specific object variable instead of referencing the object?

  • 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-06-16T01:48:23+00:00Added an answer on June 16, 2026 at 1:48 am

    You need to Override the toString() method in DescItems

    Something like this:

    @Override
    public String toString() {
         return itemDescription + " " + itemPrice + currencySymbol + " (" + itemRating + ")";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my .js file I have the following data structure var menu = {
Let's say we have a solution with the following structure: Project.DAL - Data access
I have local data in a grid. How can I get all of the
I have a simple web application which lets the user upload local user data
I currently have this code: PACKETS = {}; function AddPacket(data) local id = data.ID;
I am using PhoneGap, jQuery mobile in Xcode. I have a local xml (data.xml)
I am currently data into a local db as following: window.localStorage.setItem('QQIDVAL' + ID, JSON.stringify(this));
I have the following XML file: <xml version=1.0 encoding=utf-8?> <Data> <Parameter1>1</Parameter1> </Data> I want
I have a question about how to structure communication between a (new) Firefox extension
I have 2 databases that have the same structure, one on a local machine

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.