Code I need help to figure out

From: John. C (ciscoguru1_at_msn.com)
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( System.in) ;
                    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
                    System.out.print(c1);
                    System.out.println();
                    
            }
            
    }

    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 ciscoguru1@msn.com or just post your suggestions. Thanks in
    advance for your help.

    Sincerely,

    John C.


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

    Relevant Pages

    • Code I need help to figure out
      ... public class ConvertCharacter ... char type. ... This code refuses to compile. ... am trying to read characters from the keyboard. ...
      (comp.lang.java.programmer)
    • Code I need help to figure out
      ... public class ConvertCharacter ... char type. ... This code refuses to compile. ... am trying to read characters from the keyboard. ...
      (comp.lang.java.help)
    • Re: Writing string data in XML while Unicode build...
      ... The code would compile, but it would be suboptimal because of invoking ... There is CString constructor and assignment operation accepting YCHAR (The ... Other Char type). ... > I don't think the application is Unicode, ...
      (microsoft.public.vc.mfc)