By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,034 Members | 822 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,034 IT Pros & Developers. It's quick & easy.

Confused with a program

P: 3
Hi, I'm pretty new to JAVA and I haven't received the best help with creating programs. I am doing a program called Bunny.java and the basics about it is that you get a list of random numbers (ascending) located in a textfile. Then if an asterisk will be printed on top of the numbers if the difference between the current value and the value next is less than 50. This is a homework assignment, and my main question is this: What type of loop, array, ... will I need to make in order for the program to look at the textfile from the highest number all the way to the lowest?
Jan 12 '07 #1
Share this Question
Share on Google+
1 Reply


Ganon11
Expert 2.5K+
P: 3,652
If the numbers are already sorted from lowest to highest in the file, I'm not sure of a way to read the highest to lowest, except indirectly:

Read all of the numbers into an array of integers, and then traverse that array from end to start. This should give you your desired result.
Jan 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.