Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Hashtable

Reply
Thread Tools

Hashtable

 
 
tuurbo46@yahoo.co.uk
Guest
Posts: n/a
 
      01-24-2006

Hi

Thanks for you help guys. The dam thing still does not work. I think
my teacher should help more, but he comes out with the c...p line of,
degrees are read and not taught.

Anyway, does anybody know of a pay site where i can get some
programming problems solved (writen for me)?

Thanks again for help.

 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      01-24-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
>
> Hi
>
> Thanks for you help guys. The dam thing still does not work. I think
> my teacher should help more, but he comes out with the c...p line of,
> degrees are read and not taught.
>
> Anyway, does anybody know of a pay site where i can get some
> programming problems solved (writen for me)?


Even if you go to the pay site, you will have to address these concerns
(which I feel you haven't done adequately yet):

What does your code look like?
What is your code supposed to do?
What's the difference between what it's doing now and what it's supposed to
do?

- Oliver


 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      01-24-2006
On Tue, 24 Jan 2006 20:08:28 GMT, "Oliver Wong" <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

> A few languages use the period character. In a language I'm developing,
>it's the ~ character. E.g. "Hello"~" world!"; my rational is that it's about
>as difficult to type as the + character on a QWERTY keyboard (shift, and
>then one of the two edges of the top most row), and the shape of the
>character is vaguely reminiscent of using a string to tie two things
>together.


~ is already taken in Java. Pl/I's || is also taken.

~ would be a nice choice. It would not be confused with any other
operator if it weren't already taken and I agree it has the look of a
tie operator.

Perhaps when Unicode takes a foothold we might use \u2903 \u2908
\u2af6 \u2a6a \u2a1d \u25be for a concatenation operator.

see http://mindprod.com/jgloss/unicode.html to view the glyphs.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
tuurbo46@yahoo.co.uk
Guest
Posts: n/a
 
      01-24-2006
Hi

Currently im doing some uni homework and we have to modify a mobile
phone application. This involves starting with a blank phone, and
adding the following items:

add entry
delete entry
view
search

So far i am able to get the main screen going (as above). With this
working i can select the add entry - this works fine. At this point i
add name and telephone number and this gets saved to a hashtable. At
this point i struggle because i cannot get data from hashtable to view
names and telephone numbers. Below is the list of my code snippets

//Declared at top of source code
private TextField userName = new
TextField("Name:.","",20,TextField.ANY);
private TextField userNumber = new
TextField("Number:.","",20,TextField.ANY);

//Hashtable
Hashtable hT = new Hashtable(10);


// adding people to hashtable

else if(event.equals("Save"))

{

hT.put(userName.getString(),userNumber.getString() );

MainMenu();

}


// viewing people in hashtable - this does not work

public void View()

{

Enumeration e1=hT.keys();

while(e1.hasMoreElements())

{

userName = (String)e1.nextElement();

userNumber=(String)hT.get(userName);

display.setCurrent(userNumber);

}


//Fields for entering name and number

public void textBox()

{

display = Display.getDisplay(this);

Form f = new Form("Add:");

f.append(userName);

f.append(userNumber);

f.addCommand(backCommand);

f.addCommand(SaveCommand);

f.setCommandListener(this);

display.setCurrent(f);

}

}

Thanks guys.

 
Reply With Quote
 
Thomas Hawtin
Guest
Posts: n/a
 
      01-24-2006
Roedy Green wrote:
>
> ~ is already taken in Java. Pl/I's || is also taken.


Not necessarily a problem. + and - are used as both unary and binary
operators.

Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      01-24-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hi
>
> Currently im doing some uni homework and we have to modify a mobile
> phone application. This involves starting with a blank phone, and
> adding the following items:
>
> add entry
> delete entry
> view
> search
>
> So far i am able to get the main screen going (as above). With this
> working i can select the add entry - this works fine. At this point i
> add name and telephone number and this gets saved to a hashtable. At
> this point i struggle because i cannot get data from hashtable to view
> names and telephone numbers. Below is the list of my code snippets
>
> //Declared at top of source code
> private TextField userName = new
> TextField("Name:.","",20,TextField.ANY);
> private TextField userNumber = new
> TextField("Number:.","",20,TextField.ANY);
>
> //Hashtable
> Hashtable hT = new Hashtable(10);
>
>
> // adding people to hashtable
>
> else if(event.equals("Save"))
>
> {
>
> hT.put(userName.getString(),userNumber.getString() );
>
> MainMenu();
>
> }
>
>
> // viewing people in hashtable - this does not work
>
> public void View()
>
> {
>
> Enumeration e1=hT.keys();
>
> while(e1.hasMoreElements())
>
> {
>
> userName = (String)e1.nextElement();
>
> userNumber=(String)hT.get(userName);
>
> display.setCurrent(userNumber);
>
> }
>
>
> //Fields for entering name and number
>
> public void textBox()
>
> {
>
> display = Display.getDisplay(this);
>
> Form f = new Form("Add:");
>
> f.append(userName);
>
> f.append(userNumber);
>
> f.addCommand(backCommand);
>
> f.addCommand(SaveCommand);
>
> f.setCommandListener(this);
>
> display.setCurrent(f);
>
> }
>
> }
>
> Thanks guys.


Okay, now I have a much better understanding of what you are trying to
do. However, what do you mean by "this does not work"? What did you expect
to happen, and what is the code doing instead?

For example, "I expected for the user name to be displayed on the
screen, but instead I am getting a NullPointerException".

BTW, I notice there seems to be a closing brace missing for the method
view().

- Oliver


 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      01-25-2006
On Tue, 24 Jan 2006 23:14:16 +0000, Thomas Hawtin
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone
who said :

>Not necessarily a problem. + and - are used as both unary and binary
>operators.


Even you could, my whole reason to avoid + is so that you don't use
the same symbol for two unrelated purposes even if the compiler can
figure it out.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
tuurbo46@yahoo.co.uk
Guest
Posts: n/a
 
      01-25-2006
Hi

The missing bracket was a copy past error. The null pointer problem
has not happend on my enviroment. I cannot get it past the compiler.
The (string) in the view method shows red.

How would you now recommend i change the view method?

 
Reply With Quote
 
Damian Brunold
Guest
Posts: n/a
 
      01-25-2006
> The (string) in the view method shows red.

If TextField is some kind of widget, then you most probably need to
do something like

while(e1.hasMoreElements())
{
userName.setText((String)e1.nextElement());
userNumber.setText((String)hT.get(userName));

instead of

while(e1.hasMoreElements())
{
userName=(String)e1.nextElement();
userNumber=(String)hT.get(userName);

Damian

 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      01-25-2006

"Damian Brunold" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
>> The (string) in the view method shows red.

>
> If TextField is some kind of widget, then you most probably need to
> do something like
>
> while(e1.hasMoreElements())
> {
> userName.setText((String)e1.nextElement());
> userNumber.setText((String)hT.get(userName));
>
> instead of
>
> while(e1.hasMoreElements())
> {
> userName=(String)e1.nextElement();
> userNumber=(String)hT.get(userName);


Damian's suggestion here looks promising. But if it doesn't solve your
problem, perhaps you could give the exact error message that the compiler is
giving you?

- Oliver


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: hashtable or map? (map inserts not behaving as I expect - and I cant find a decent simple example for hashtable) Kai-Uwe Bux C++ 1 12-21-2008 09:25 PM
Problem with hashTable Guillermo Perl 1 03-04-2004 12:43 PM
Type Hashtable not defined diya ASP .Net 1 10-31-2003 06:59 PM
Get Hashtable Object Directly John E ASP .Net 1 10-08-2003 12:40 PM
vbc compilation fails when using Hashtable Jonathan Wolfson ASP .Net 1 06-27-2003 04:40 PM



Advertisments