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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:56:33+00:00 2026-06-15T13:56:33+00:00

Been given the task of creating a Wallet class where you can create members

  • 0

Been given the task of creating a Wallet class where you can create members and transfer money between them. The user can then pick who gives the money and who receives it. Here is a little of the relevant code:

Wallet adamsWallet = new Wallet("Adam", 403.50);
Wallet bentsWallet = new Wallet("Bent",  873);
Wallet clarksWallet = new Wallet("Clark", 319.50);


object_name_here.transfer(other_object_name_here, 200);

So I want the user for example to enter “adam” in the Scanner, then somehow append “sWallet” to adam and then use that as the object name for the method call.

How can I do that or is there a better way of doing 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-06-15T13:56:34+00:00Added an answer on June 15, 2026 at 1:56 pm

    Use a Map to store the wallets. For example:

    Map<String, Wallet> wallets = new HashMap<>();
    
    wallets.put("Adam", new Wallet("Adam", 403.50));
    wallets.put("Bent", new Wallet("Bent",  873));
    wallets.put("Clark", new Wallet("Clark", 319.50));
    

    You can lookup a wallet by name from the map.

    Wallet wallet1 = wallets.get("Adam");
    Wallet wallet2 = wallets.get("Clark");
    
    wallet1.transfer(wallet2, 200);
    

    Note that objects do not have names – variables have names. An object is not a variable; a variable is a reference to an object. You can have multiple variables that refer to the same object.

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

Sidebar

Related Questions

I have been given a task to create a bridge between C# and Java.
I've been given the task to create a simple Silverlight chat box for two
I have been given a new task from the client which is basically creating
I have been given a task to create a Python file that will take
I've been given the task to implement a new end-user functionality into a Java/Swing
I have been given the task of creating a sql database and creating a
I have been given a task of creating a common Gridview component which has
Hi I've been given the task of creating an N-Teir website using the Entity
I've recently been given the task of creating an Audit on a database table
I have been given a task to calculate the number of days between 2

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.