Re: Is there a better way to do this?



On 28 Jul 2007 01:02:55 GMT, John <jtlinux1@xxxxxxxx> wrote, quoted or
indirectly quoted someone who said :

Anyway, here's a link to my code. I'd appreciate any comments or critisim. I think it's a good first attempt, but it's not something I'd want to turn in to a professor, yet.

http://sparklesthecat.is-a-geek.com/code/Hello.java

ArrayLists are for when you don't know in advance how many elements
you will have. Arrays are for when you do. If you flip your code
from ArrayList to Array you will see it becomes much more readable and
faster.

Not to worry about the loss of Collections.sort. See Arrays.sort.
See http://mindprod.com/jgloss/sort.html

also try to convert any FOR to for:each.. That greatly enhances
readability.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
.



Relevant Pages

  • Re: does C# have any collection objects that support sort functionality so that I dont have to writ
    ... the IComparable interface. ... Also, since arrays are strongly typed, you know that all elements are of the ... for ArrayLists. ... The Sort() method will utilize each object's IComparable ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Is there a better way to do this?
    ... ArrayLists are for when you don't know in advance how many elements ... Arrays are for when you do. ... readability. ... I knew I could have implemented a bubble sort or insertion sort or ...
    (comp.lang.java.help)
  • Re: Need advice on data structures
    ... I'm having some difficulties in deciding which type of data structure ... You need a Movie class ... You don't want ordinary arrays. ... You can do nested ArrayLists, but you don't want that either. ...
    (comp.lang.java.help)
  • Re: Will memory get over-used?
    ... or have a poor memory.. ... Note that this is talking about ARRAYS. ... array will be that of a bunch of references, ... Arrays are not the same as objects and ArrayLISTs ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Array and ArrayList
    ... dynamic size of ArrayLists I would like to clarify some points: ... Arrays are immutable. ... As a result of this immutability looping over arrays for example are well ...
    (microsoft.public.dotnet.languages.csharp)