Code I need help to figure out

From: John. C (
Date: 03/28/04

  • Next message: Fahd Shariff: "Re: Code I need help to figure out"
    Date: 28 Mar 2004 13:40:21 -0800

    Dear Group Members,

    I need help. I need your help to figure out what I am doing wrong
    about this (enclosed) juvenile code below:

    public class ConvertCharacter
            public static void main(String [ ] args)
                    InputStreamReader k = new InputStreamReader( ;
                    BufferedReader input = new BufferedReader (k);
                    // tells user to enter characters from keyboard
                    System.out.println("Please enter a character");
                    String text = input.readLine(); // reads character input.
                    // char c1, c2;
                    char c1 = new Character(text).charValue(); // converts string input
    to char type
                    char c2 = new Character(text).charValue();
                    System.out.print(c2); // prints characters in reversing other

    Yes go ahead and laugh at me. This code is very basic and I do not
    know how to figure it out. It's okey, I just want to learn more of
    this stuff. Go ahead, I can take it.

    The problem is how to convert the input string from the keyboard to a
    char type.

    This code refuses to compile. It is straight to the point, I think. I
    am trying to read characters from the keyboard. I just do not know
    what I am doing wrong in this code. I had written and compiled other
    codes using this method.

    Help me Java community. I come to you with all humility. Send me an
    email at or just post your suggestions. Thanks in
    advance for your help.


    John C.

  • Next message: Fahd Shariff: "Re: Code I need help to figure out"