Search code examples
javacannot-find-symbol

What is wrong with my code? I am a beginner and I keep getting this cannot find symbol error


I am unsure what to do from here. Please let me know what I am doing wrong and how I can fix it. Thank you. I have looked though many posts and anything I do just adds to the problem. Again, I have only been coding for a few days now.

     public class TestRun {
        public static void main(String[] args) {
            char Button = '1';
                switch (Button) { 
                    case '1': System.out.prntln(" return ") ;
                        break;
                    case '2': System.out.prntln(" enter ") ;
                        break;
                    case '3': System.out.prntln(" welcome ") ;
                        break;
                    default: System.out.prntln(" hello ") ; 
        }
    }
}

/Users/levi_kline/Desktop/TestRun.java:5: error: cannot find symbol
                case '1': System.out.prntln(" return ") ;
                                    ^
  symbol:   method prntln(String)
  location: variable out of type PrintStream
/Users/levi_kline/Desktop/TestRun.java:7: error: cannot find symbol
                case '2': System.out.Prntln(" enter ") ;
                                    ^
  symbol:   method Prntln(String)
  location: variable out of type PrintStream
/Users/levi_kline/Desktop/TestRun.java:9: error: cannot find symbol
                case '3': System.out.prntln(" welcome ") ;
                                    ^
  symbol:   method prntln(String)
  location: variable out of type PrintStream
/Users/levi_kline/Desktop/TestRun.java:11: error: cannot find symbol
                default: System.out.prntln(" hello ") ; 
                                   ^
  symbol:   method prntln(String)
  location: variable out of type PrintStream
4 errors
[Finished in 1.1s]

Solution

  • You are calling a method that does not exist. It is println not prntln.

    I highly recommend using the built in code recommendation in your IDE or read the javadoc beforehand so you know the correct names and arguments.