Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Char error

  1. #1
    Junior Member
    Join Date
    Aug 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Char error

    can anyone help me? why it say cannot found symbol nextChar?

    import java.util.Scanner;

    //class chargrade
    public class chargrade
    {
    public static void main(String [] args)
    {
    char grade ;

    Scanner get = new Scanner(System.in);
    grade = get.nextChar();


    switch (grade)
    {
    case 'A': System.out.println("excellant");
    break;
    case 'B': System.out.println("GOOD");
    break;
    case 'C': System.out.println("THINK OK");
    break;
    case 'D': System.out.println("THINKING");
    break;
    case 'E': System.out.println("EXERSISE MORE");
    break;
    case 'F': System.out.println("FAILED");
    break;
    default: System.out.println("please enter A to E");
    break;
    }
    }
    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Char error

    Please refer to the Scanner API page to review the available methods. You'll see that nextChar() isn't there.

  3. #3
    Member
    Join Date
    Jul 2013
    Posts
    219
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default Re: Char error

    Hello.
    Instead of nextChar(), try nextByte() and see if it fulfills your requirements.

    Syed.

  4. #4
    Junior Member
    Join Date
    Sep 2012
    Posts
    20
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Char error

    or...since there's no nextChar(), look for findWithinHorizon such as

    To find within the next count characters : ScannerFileJava Tutorial


    p/s: learn to look for javadoc, at least google for used method on java.util.Scanner. this will save your time.

Similar Threads

  1. String.split"char"; error
    By bean in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 3rd, 2013, 05:30 PM
  2. Replies: 3
    Last Post: March 23rd, 2013, 07:20 PM
  3. Get int value from char, char pulled from String
    By Andrew Red in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 4th, 2013, 10:04 AM
  4. Replies: 2
    Last Post: September 23rd, 2011, 07:09 AM
  5. Char cannot be dereferenced!! Please help
    By humdinger in forum Object Oriented Programming
    Replies: 5
    Last Post: February 14th, 2010, 03:18 PM