File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes JavaBat Array Problem (larger value w/o loop) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JavaBat Array Problem (larger value w/o loop)" Watch "JavaBat Array Problem (larger value w/o loop)" New topic
Author

JavaBat Array Problem (larger value w/o loop)

W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
I am working through the Javabat exercises and I encountered one that asking me to figure out if the first value in an array of 3 is larger than the last value in the array and set all the values in the array to the larger of the two values. The kicker is it is in a section that says it can be done without using a loop construct. Now I could (easily) handle this with a if loop, and the code would work, but I can't think of a way to do with without a loop. I'm not going to copy/paste the problem, and I don't want anyone to write the code for me (I'm trying to learn here, people!) but if anyone has a brilliant, crazy, or ridiculously simple path to point me down it would be greatly appreciated!


SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

"if" is not a loop; it's a control structure. "while", "for" and "do/while" are loops. I don't think you were asked to do this without "if".


[Jess in Action][AskingGoodQuestions]
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
Ah. That makes my life much simpler. I'm not sure why I thought of an if statement as a loop....

Maybe I spent too long today staring blankly at code I didn't understand...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaBat Array Problem (larger value w/o loop)