wood burning stoves
The moose likes Beginning Java and the fly likes while loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "while loop" Watch "while loop" New topic

while loop

richard stockman

Joined: Apr 11, 2006
Posts: 11
When trying a simple while loop is it correct that it will not work unless any variables are actually given a value rather then just delaring them as ints.
eg - This will not compile.

Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
If a primitive is not initialized, it has no value, therefore it can not be compared, so a compiler error makes sense.

As an aside an easier way to do that without loops is n(n+1)/2.
[ April 23, 2006: Message edited by: Rusty Shackleford ]

"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
A local variable has to be initialized by the programmer before you try to use its value.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: while loop
It's not a secret anymore!