Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // HW
- public class PhoneBook
- {
- final int SIZE = 10; // can be changed
- String[] names = new String[SIZE];
- public String[] search(String input)
- {
- String[] results = new String[SIZE];
- boolean equal;
- int nextIni = 0;
- for(int i = 0; i < SIZE; i++)
- {
- equal = true;
- for(int j = 0; j < input.length() && equal; j++)
- {
- if(input.charAt(j) != names[i].charAt(j))
- equal = false;
- }
- if(equal)
- {
- results[nextIni] = names[i];
- nextIni++;
- }
- }
- return results;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment