Re: Is there a better way to do this?
- From: JT <jtlinux1@xxxxxxxx>
- Date: 28 Jul 2007 09:14:38 GMT
On Sat, 28 Jul 2007 08:08:57 +0000, Roedy Green wrote:
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.
Yeah, I knew I could have implemented a bubble sort or insertion sort or
something like that, but the Collections.sort lets me do it in one line.
And thanks for the tip about for:each I knew there was something like
that but I didn't feel like looking it up :-)
.
- Follow-Ups:
- Re: Is there a better way to do this?
- From: Roedy Green
- Re: Is there a better way to do this?
- References:
- Is there a better way to do this?
- From: John
- Re: Is there a better way to do this?
- From: Roedy Green
- Is there a better way to do this?
- Prev by Date: Re: Isn't Date deprecated? Use Calendar instead.
- Next by Date: Re: Exchanging information
- Previous by thread: Re: Is there a better way to do this?
- Next by thread: Re: Is there a better way to do this?
- Index(es):
Relevant Pages
|