Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #36447
| From | Martin Gregorie <martin@address-in-sig.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: hash map |
| Date | 2017-04-16 19:10 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <od0fj0$fes$1@dont-email.me> (permalink) |
| References | <9a86c6fb-ae40-4acd-902f-afff0ab60fd6@googlegroups.com> |
On Sun, 16 Apr 2017 11:53:43 -0700, pablo wrote:
> hi all i am trying to add to a hash map but i cant seem to do it could
> somebody look at the code and tell me why the hell i cant add the key
> and value
>
> import java.util.*;
> /**
> * The class Garage is used to hold data about a collection of
> customers.
> *
> * @author M250 module team * @version 1.0 */
> public class Garage {
> //garage creating an empty instance of map map private
> Map<String,Customer> Customer = new HashMap<String, Customer>();
>
>
> public Garage()
> {
> Customer = new HashMap<>();
> }
>
> public void addCustomer(String Customer)
> {"
> Customer.Put(Andrew Smith, address 1 The High Street", area 1,
> "123ABC");
> }
I see three problems:
1) since you've declared an instance of HashMap<String,Customer> as a
private instance, why are you trying to replace it in in a Constructor?
2) What are you trying two achieve by using three different class types
in the two statements?
3) Why are you trying to use a non-existent method in your add() method
and what, exactly are you trying to store on the Customer map?
If you haven't downloaded the documentation for the standard Class
library yet, do so, bookmark it in your web browser and use it when
you're writing code. Having the class definitions and tutorials available
will help you a lot.
4) Some other points to think about and check in whatever text you're
learning Java from:
- don't capitalise the first name of a variable or method name. Names
starting with a capital should only be used for class names.
- try putting your string delimiters in the right places
- balance your curly brackets: EVERY { needs a closing } and
if you always put opening and closing brackets at the same indent
you'll find making them match gets easier.
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
hash map pablo <pa24959122@gmail.com> - 2017-04-16 11:53 -0700
Re: hash map Martin Gregorie <martin@address-in-sig.invalid> - 2017-04-16 19:10 +0000
Re:hash map omegajunior <omegajunior@protonmail.com> - 2017-04-16 17:11 -0400
Re: hash map pablo <pa24959122@gmail.com> - 2017-04-17 04:31 -0700
Re: hash map Eric Douglas <e.d.programmer@gmail.com> - 2017-04-17 05:11 -0700
Re: hash map pablo <pa24959122@gmail.com> - 2017-04-17 05:32 -0700
Re: hash map Eric Douglas <e.d.programmer@gmail.com> - 2017-04-17 05:58 -0700
Re: hash map Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-04-17 09:10 -0400
Re: hash map pablo <pa24959122@gmail.com> - 2017-04-17 06:53 -0700
Re: hash map Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-04-17 10:15 -0400
Re: hash map pablo <pa24959122@gmail.com> - 2017-04-17 07:25 -0700
Re: hash map Eric Douglas <e.d.programmer@gmail.com> - 2017-04-17 07:46 -0700
Re: hash map Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-04-17 10:54 -0400
Re: hash map pablo <pa24959122@gmail.com> - 2017-04-17 08:29 -0700
Re: hash map Eric Douglas <e.d.programmer@gmail.com> - 2017-04-17 08:44 -0700
Re: hash map Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-04-17 12:07 -0400
Re: hash map pablo <pa24959122@gmail.com> - 2017-04-17 09:32 -0700
Re: hash map Martin Gregorie <martin@address-in-sig.invalid> - 2017-04-17 23:14 +0000
Re: hash map Arne Vajhøj <arne@vajhoej.dk> - 2017-04-17 20:22 -0400
Re: hash map Martin Gregorie <martin@address-in-sig.invalid> - 2017-04-18 01:20 +0000
Re: hash map Arne Vajhøj <arne@vajhoej.dk> - 2017-04-18 20:01 -0400
Re: hash map Martin Gregorie <martin@address-in-sig.invalid> - 2017-04-19 09:02 +0000
Re: hash map Eric Douglas <e.d.programmer@gmail.com> - 2017-04-18 04:54 -0700
Re: hash map Arne Vajhøj <arne@vajhoej.dk> - 2017-04-18 20:03 -0400
Re: hash map Martin Gregorie <martin@address-in-sig.invalid> - 2017-04-19 08:55 +0000
Re: hash map Eric Douglas <e.d.programmer@gmail.com> - 2017-04-19 04:45 -0700
Re: hash map Arne Vajhøj <arne@vajhoej.dk> - 2017-04-18 20:05 -0400
csiph-web