Results 1 to 4 of 4
  1. #1
    nadissen is offline Member
    Join Date
    Mar 2011
    Posts
    11
    Rep Power
    0

    Post concatenate two char into one char

    the title is quite explicit, here the problem:

    char a = 'a';
    char b = 'b';
    char c = a+b; <-not correct

    System.out.print(c);
    rather than printing "ab" (which is what i want), the program prints the ASCII value for sum of 'a' and 'b' (which is not what i want)

    can someone help??

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    "ab" is not a char and never can be (is it truly a single char?) but a String, and I think that's what you really want to use here, Strings.

  3. #3
    asmitarnd is offline Member
    Join Date
    Mar 2011
    Posts
    22
    Rep Power
    0

    Default

    try this
    String st="a";
    String st1="b";
    String st3=st+st1;
    System.out.println("last string"+st3)

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default

    asmitarnd, please stop polluting the forum with useless garbage that either answers an already answered question without adding anything new, or, as in this case, doesn't address the problem at all.

    db

Similar Threads

  1. Replies: 2
    Last Post: 03-08-2011, 06:20 AM
  2. check a string char by char
    By Sotsiak in forum New To Java
    Replies: 2
    Last Post: 10-23-2010, 09:24 PM
  3. replaceALL(char oldChar, char newChar) method
    By arson09 in forum New To Java
    Replies: 0
    Last Post: 04-28-2010, 05:48 AM
  4. JNA char **
    By H_P in forum Advanced Java
    Replies: 0
    Last Post: 01-14-2010, 11:13 PM
  5. drawing char by char with Graphics
    By diggitydoggz in forum New To Java
    Replies: 5
    Last Post: 12-27-2008, 12:49 PM

Tags for this Thread

Posting Permissions

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