Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2007
    Posts
    10
    Rep Power
    0

    Default Char type for first character typed?

    Im trying to find out a way to search the next character in "char" type.

    For instance, if i wanted to find out a way to search the next character in "int" type, i would put out nextInt();

    I want to essentially know how to do that with char, and with a character, not a number.

  2. #2
    Join Date
    Jul 2007
    Posts
    10
    Rep Power
    0

    Default

    also, i know of findInLine(".").charAt(0), but for some reason, it's coming out as a nullpointer exception when i use it

  3. #3
    Join Date
    Jul 2007
    Posts
    10
    Rep Power
    0

    Default

    ok, i just need to find out how to get rid of the nullpointerexception...

  4. #4
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    9

    Default

    Char type hold only one character. You can't obtain first character of a character. :) Why did not you try the solution i gave you in your previous thread?

    Java Code:
    String reply = myScanner.nextLine();
    if (reply.charAt(0) == 'Y') hasCoupon = true;
    else hasCoupon = false;

Similar Threads

  1. Casting an int value into a char
    By kurtulas in forum New To Java
    Replies: 2
    Last Post: 02-16-2008, 09:03 PM
  2. reading text character by character
    By bugger in forum New To Java
    Replies: 2
    Last Post: 11-09-2007, 09:54 PM
  3. Char to String in java
    By trill in forum New To Java
    Replies: 1
    Last Post: 08-01-2007, 02:42 PM
  4. Help with, String, Char
    By lenny in forum New To Java
    Replies: 1
    Last Post: 07-25-2007, 03:58 PM
  5. First Typed via video instruction
    By ZAXTHEGREAT in forum New To Java
    Replies: 15
    Last Post: 07-23-2007, 05:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •