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 3 of 3

Thread: how is the correct declaration of character? I need it now. Somebody help

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Location
    Philippines
    Posts
    7
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post how is the correct declaration of character? I need it now. Somebody help

    import java.io.*;
    public class erere
    {
    public static void main(String[]args)throws IOException
    {
    BufferedReader cin=new BufferedReader(new InputStreamReader(System.in));

    String a;
    Double c;
    Float e;
    char d;

    System.out.print("Enter a:"+"");
    a=cin.readLine();


    System.out.print("Enter c:"+"");
    c=Double.parseDouble(cin.readLine());

    System.out.print("Enter d:"+"");
    d=cin.readLine();

    System.out.print("Enter e:"+"");
    e=Float.parseFloat(cin.readLine());


    }
    }



    --------------------Configuration: <Default>--------------------
    C:\projj\erere.java:21: incompatible types
    found : java.lang.String
    required: char
    d=cin.readLine();
    ^
    1 error

    Process completed.

    I don't know what's the problem really is. please help me =(


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,322
    My Mood
    Mellow
    Thanks
    253
    Thanked 780 Times in 765 Posts

    Default Re: how is the correct declaration of character? I need it now. Somebody help

    Please post your code in code tags.

    The error message is telling you what's wrong. Hint: What does the method BufferedReader.readLine() return?

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Location
    Philippines
    Posts
    7
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how is the correct declaration of character? I need it now. Somebody help

    sorry idk how to post in code tags cauz i'm just new here. XD
    BufferedReader is used for string, right?
    so what should i use for character? DataInputStream?
    i'm just a beginner in java btw

    --- Update ---

    in a very long searching in the net, i finally found one. ))))))

Similar Threads

  1. What is the problem with this following declaration in JDK 1.4?
    By Senjuti in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 2nd, 2011, 12:37 PM
  2. [SOLVED] Constructor and declaration issues
    By Gthoma2 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 28th, 2011, 12:16 AM
  3. Variable declaration placement
    By 2nickpick in forum Java Theory & Questions
    Replies: 2
    Last Post: January 22nd, 2011, 11:34 AM
  4. The character '' is an invalid XML character exception getting
    By sumanta in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 9th, 2010, 12:13 PM
  5. [SOLVED] Method declaration in Java
    By mohsendeveloper in forum Object Oriented Programming
    Replies: 4
    Last Post: June 11th, 2009, 04:18 AM

Tags for this Thread