-2

I want to create two string arrays with words i give through a scanner, but the compiler keeps telling me "cannot find symbol variable in" in Scanner.in. How do i solve it?

    import java.util.Scanner;

    public class FollowerInsight {  

        public static void main (String[] args) {
            Scanner fr = new Scanner(Scanner.in);
            Scanner fg = new Scanner(Scanner.in);

            String followers[] = new String[fr];
            String following[] = new String[fg];
    }
}

Now its giving me "incompatible types: java.util.Scanner cannot be converted to int" on fr and fg. What should i do?

    String followers[] = new String[fr];
    String following[] = new String[fg];

What im trying to do is to connect what I wrote on the scanner to fill the string list. Im sorry im new on programming

1 Answers1

2

Scanner has no input stream called in. I believe what you wanted was System.in which is the standard input stream which reads from the console:

The "standard" input stream. This stream is already open and ready to supply input data. Typically this stream corresponds to keyboard input or another input source specified by the host environment or user.

Scanner fr = new Scanner(System.in);

Also it is best to only have one Scanner object reading from System.in. Next, what is

 String followers[] = new String[fr];

Supposed to do? I think you're trying to read input from the console (You probably want to use the nextLine() and next() methods) to read input and put them in your String[]

Please read the docs for the Scanner class.

GBlodgett
  • 12,704
  • 4
  • 31
  • 45