×

Discussion Board

Results 1 to 2 of 2

Thread: noob question

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    6

    noob question

    sorry but after search and mutltiple test i can't get to transform an integer into chararchter

    i tried

    int i;
    char j;

    j=i.charValue();

    or

    int i;
    string j;
    j=i.toString();

    none would work

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    i and j in your examples are primitive types. Primitive types don't have any methods because they are not classes.
    You need to use the wrapper classes for those types to use those methods you are trying to use:
    Code:
    int i = 7;
    Integer num = new Integer(i);
    String s = num.toString();
    or even better, directly with the static method:
    Code:
    int i = 7;
    String s = Integer.toString(i);
    shmoove

Posting Permissions

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