I'm still plugging away with all these arrays and so forth, but I'm mow trying to search through an array. The array is sorted using a Bubble Sort Algorithm, and I've written a main class to test the searching capabilities.
The problem is that the output, when I run the main class, is simply freezing and not giving any data. It does not even request a number to input.
A bit perplexed at the moment!
Anyway, my code is as follows:
It's probably something really simple, but I just can't see it at the moment.
1. The search method from the BubbleSort class:
public int search(int givenNumber)
for (int i=0; i <numbers.length; i++)
if (numbers[i] == givenNumber)
2. The main class for testing the search method:
public class NumberTester
public static void main(String args)
SimpleWriter screen = new SimpleWriter(System.out);
SimpleReader keyboard = new SimpleReader(System.in);
BubbleSort internal = new BubbleSort("tester.txt");
boolean done = false;
System.out.print("Enter number to search for, -1 to quit: ");
int givenNumber = keyboard.readInt();
if (givenNumber == -1)
done = true;
int pos = internal.search(givenNumber);
System.out.println("Found number in position " + pos);
Any help really appreciated!!