0

i have a file called elements.txt saved into my class, and src. what am i doing wrong?

import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
public class periodicTable
{
  static Chemical_Elements[] el;
  public static void main(String[] args) throws FileNotFoundException
{

    File file = new File ("elements.txt");
    Scanner scan = new Scanner (file);
    System.out.println(file);
ian
  • 1
  • 1
    You have to *use* the Scanner object. e.g. `String line = scan.nextLine()`. – colti Mar 13 '15 at 21:38
  • 1
    `"What am I doing wrong?"` -- You're not reading a tutorial before you try to use a tool. This is not a good plan for how to learn to program. Simply Google `Java Scanner Tutorial` and you'll get dozens of useful hits, any one of them would help you set your code straight. In fact please check the first hit: [Google Java Scanner Tutorial Search](https://www.google.com/?gws_rd=ssl#q=java+scanner+tutorial). – Hovercraft Full Of Eels Mar 13 '15 at 21:41
  • 1
    Why create a `Scanner` if you aren't going to use it? – Sotirios Delimanolis Mar 13 '15 at 21:41

0 Answers0