Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class Searchers {
- public static void main(String[] args)
- throws FileNotFoundException {
- List<Integer> nums = readNumbers("nums.txt");
- System.out.println(nums.indexOf(2));
- }
- public static List<Integer> readNumbers(String filename)
- throws FileNotFoundException {
- List<Integer> numbers = new ArrayList<Integer>();
- Scanner input = new Scanner(new File(filename));
- while (input.hasNextInt()) {
- numbers.add(input.nextInt());
- }
- return numbers;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement