I am trying to create a tree map within a TreeMap.
Any help would be great.
goes a bit like this: -
public class ChessImpl implements CHESS
-
{
-
private Map<String, Integer> name;
-
private int membernumber;
-
private Map<String, Map<Integer, Holding>> stock;
-
private Map<Integer, Holding> intSearch;
-
private Holding holder;
-
-
-
public ChessImpl()
-
{
-
name = new TreeMap<String, Integer>();
-
membernumber = 1;
-
stock = new TreeMap<String, Map<Integer, Holding>>();
-
}
-
With the stock map do I need to create another map before i insert it?
Main problem is when i use the put method it wont accept it? -
public void issue(String stockCl, String client, int nshares)
-
{
-
if(name.containsKey(client) && (nshares > 100))
-
{
-
Holding holder = new Holding(stockCl, client, nshares);
-
int memNum = name.get(client);
-
stock.put(stockCl, (memNum, holder)) //THIS IS WHERE IM HAVING THE MAJOR PROBLEM
-
}
-
else
-
{
-
System.out.println("Client name has not been created or the amount of shares is less than 100");
-
}
-
I keep getting a error message. this is the holding class just for refrence. -
public class Holding
-
{
-
-
private String stock;
-
private String client;
-
private int shares;
-
public Holding(String stock, String client, int shares)
-
{
-
this.stock = stock;
-
this.client = client;
-
this.shares = shares;
-
}
-
3 2869
I keep getting a error message.
What is the exact error message? Is it a compilation error or a runtime error?
kind regards,
Jos
I am trying to create a tree map within a TreeMap.
Any help would be great.
goes a bit like this: -
public class ChessImpl implements CHESS
-
{
-
private Map<String, Integer> name;
-
private int membernumber;
-
private Map<String, Map<Integer, Holding>> stock;
-
private Map<Integer, Holding> intSearch;
-
private Holding holder;
-
-
-
public ChessImpl()
-
{
-
name = new TreeMap<String, Integer>();
-
membernumber = 1;
-
stock = new TreeMap<String, Map<Integer, Holding>>();
-
}
-
With the stock map do I need to create another map before i insert it?
Main problem is when i use the put method it wont accept it? -
public void issue(String stockCl, String client, int nshares)
-
{
-
if(name.containsKey(client) && (nshares > 100))
-
{
-
Holding holder = new Holding(stockCl, client, nshares);
-
int memNum = name.get(client);
-
stock.put(stockCl, (memNum, holder)) //THIS IS WHERE IM HAVING THE MAJOR PROBLEM
-
}
-
else
-
{
-
System.out.println("Client name has not been created or the amount of shares is less than 100");
-
}
-
I keep getting a error message. this is the holding class just for refrence. -
public class Holding
-
{
-
-
private String stock;
-
private String client;
-
private int shares;
-
public Holding(String stock, String client, int shares)
-
{
-
this.stock = stock;
-
this.client = client;
-
this.shares = shares;
-
}
-
Quick answer: Yes, you must create an Object, before using it. Instead of -
stock.put(stockCl, (memNum, holder));
-
you want something like -
TreeMap tmpMap = new TreeMap();
-
tmpMap.put(memNum, holder);
-
stock.put(stockCl, tmpMap);
-
That should do the job.
Greetings,
Nepomuk
Thanks for the suggestions ill try that code 2nite.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mark Wayne |
last post by:
Is is possible to use TreeMap in the javascript <SCRIPT> portion of HTML? If
so, how?
Thanks,
mark
|
by: Nick |
last post by:
Hi,
I have a windows application, wherein the solution consists of 5 projects.
When I try to create a setup and deployment project for this solution, I'm
somehow unable to add anything in...
|
by: EnglishMan69 |
last post by:
Hello All,
I am using VB2005 Beta 2 in VS 2005 and am running into a small
problem. I need to be able to add a picture box to the main form from
within a thread.
The program goes to a web...
|
by: Mats Lycken |
last post by:
Hi,
I'm creating a CMS that I would like to be plug-in based with different
plugins handling different kinds of content.
What I really want is to be able to load/unload plugins on the fly
without...
|
by: treeman |
last post by:
I copied the example
Compile is successful .net 2003
but i press button , nothing to show
but the example has box show up, why ? where 's wrong?
|
by: Treeman |
last post by:
I copied the example
Compile is successful .net 2003
but i press button , nothing to show
but the example has box show up, why ? where 's wrong?
|
by: Thiero |
last post by:
I am a studend in programming and I find it difficult to use treemap, can any one help me on how to use treemap.
Specially the purpose is to use treemap and give a list of students firstname...
|
by: Dan |
last post by:
Hi,
I use the <asp:CreateUserWizardcontrol for creating memberusers. In that
windows, one must provide an emailaddress.
My question is: how can an user later change his emailaddress?
Thanks...
|
by: twdo |
last post by:
OK. I am totally frustrated here. I have a setup project within Visual
Studio. That setup project is calling a class library project by the
use of Custom Actions. Within that class library (my...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |