[Beds] Java Question
David Pashley
david at davidpashley.com
Tue Dec 6 14:31:04 GMT 2005
On Dec 06, 2005 at 14:13, Stephen Elliott praised the llamas by saying:
> 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...
The answer is to use a container. Perhaps a List. You can create a List
and then .append() items onto it.
--
David Pashley
david at davidpashley.com
Nihil curo de ista tua stulta superstitione.
More information about the Beds
mailing list