[Beds] Java Question

Stephen Elliott techweb at ntlworld.com
Wed Dec 7 12:16:52 GMT 2005


Hi,

Still having no joy getting it working within my code.

Cheers for all your guidance.

-----Original Message-----
From: David Pashley [mailto:david at davidpashley.com]
Sent: 07 December 2005 12:02
To: Stephen Elliott
Cc: beds at mailman.lug.org.uk
Subject: Re: [Beds] Java Question


On Dec 07, 2005 at 10:08, Stephen Elliott praised the llamas by saying:
> Hi,
>
> Cheers for your help guys. I could not get that to work, came up with
unable
> to resolve symbol errors amongst other things.
>
> Unfortunately my knowledge of Java isn't all that great.
>
> Steve...
>

You're lucky, because I was playing with this yesterday, so I know what
is going on now.

import java.util.*;

List list = new Vector();
list.add("foo");

Iterator it = list.iterator();
while(it.hasNext()) {
   String current = (String)it.next();
   System.out.println(current);
}

You really want to use iterators as it means you can change your list
from say a List to a Set or a Hash and it will still work.

>
>
> Hi ,
>
>
> Try this:
>
>
>
> ArrayList _arrayList = new ArrayList();
> _arrayList.add("blablahbla");
>
>
> for (int j = 0; j < _arrayList.size(); j++) {
> 		System.out.println(_arrayList.get(j));
> }
>
> Rgds Mike
>
>
>
>
> Hi there,
>
>
> I have a quick Java question I'd like to run past any Java Gurus out
> there. I am writing a multi-thread chat server programming using RMI and
> want to store all the messages users send to each other in an array. The
> purpose being, when someone new joins the chat room they will receive
> all previous messages users have sent to one another. So far all I can
> do is store a predefined amount e.g. 100. I have achieved this by
> creating a string array with 100 elements. What I would like to do is be
> able to store an infinite number of messages but is it possible to
> create an array with an infinite number of elements.
>
> I hope what I have said makes sense, this is as you've probably guessed
> an assignment we have been given at University. I have asked my lecturer
> and he says this is beyond the scope of the course but to me it seems
> foolhardy to write a program that will crash once 100 messages have been
> relayed.
>
> Many Thanks
> Steve...

--
David Pashley
david at davidpashley.com
Nihil curo de ista tua stulta superstitione.
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.13.12/193 - Release Date: 06/12/2005

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.13.12/193 - Release Date: 06/12/2005




More information about the Beds mailing list