Java System.out.println() throwing error

So I'm coming back to Java after a long time of not working with it. First method of my first class and I'm seeing an error I've never seen before.

For every System.out.println() statement I have, the .out. part throws this error: cannot find symbol symbol: variable out location: class System

my class is unfinished but looks like this

import java.io.*;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class System{
//Variables
char map[];
/*
Functions
FILE INPUT 
*/
public static void ReadFile(){
    FileInputStream fstream;
    try{
        fstream = new FileInputStream("C:\\Users\\James\\Documents\\NetBeansProjects\\Assignment1\\src\\testfiles");
        BufferedReader br = new BufferedReader(new InputStreamReader(fstream));

        String strLine;

        System.out.println("Your Input File");
        System.out.println("****************");

        //Read File Line By Line
        while ((strLine = br.readLine()) != null)   
        {
            // Print the content on the console
            System.out.println(strLine);
            inputArray.add(strLine);
        }

        System.out.println("****************");
        //Close the input stream
        br.close();
        System.out.println();
    } 
    catch (FileNotFoundException e)
    {
        e.printStackTrace();
    }
  }
}

Every single .out. in this block of code throws this error :cannot find symbol symbol: variable out location: class System

I am using Netbeans8.0.2 and java 1.7.0_76(because I have to)

Can someone shed some light on this?

Jon Skeet
people
quotationmark

This is the problem:

public class System

You're creating your own class called System, so when you later use:

System.out.println

that's looking in your System class rather than java.lang.System.

Options:

  • Change the name of your class. It's generally a bad idea to create classes with the same name as classes within java.lang, precisely for this reason
  • Fully-qualify the call:

    java.lang.System.out.println(...);
    

I'd pick the former option, personally.

people

See more on this question at Stackoverflow