Compilation problem

Discussion in 'Java' started by Petterson Mikael, Jun 8, 2006.

  1. Hi,

    In a java source file we have the following:

    String value = Boolean.toString(succeed);

    When we compile we get:

    Cannot resolve symbol toString()

    We use jdk1.3.1_03_b03 mixed mode ( Solaris)

    When we compile the same code on ( Linux) but with

    jdk1.3.1_11 I get no compilation error.

    Is it allowed to have major changes in the api even
    if the the 1.3.1 is not changed? Or is this a bug in
    the compiler?

    cheers,

    //mikael
    Petterson Mikael, Jun 8, 2006
    #1
    1. Advertising

  2. Petterson Mikael

    Alex Whitney Guest

    That's because Boolean does not have a static toString() method.
    toString() is invoked on an object, not called the way you were doing
    it. At least according to the 1.3 API.

    I've never used 1.3, but in 1.4+ you can do what you want like this:
    String value = succeed + "";

    I'm guessing you want the String "conversion" of a boolean for output.
    If so, you can always do something like this:
    System.out.println ("The value of succeed is " + succeed);

    And if that doesn't work (if it wasn't implemented back then), you can
    do:
    String value = String.valueOf (succeed);

    Petterson Mikael wrote:
    > Hi,
    >
    > In a java source file we have the following:
    >
    > String value = Boolean.toString(succeed);
    >
    > When we compile we get:
    >
    > Cannot resolve symbol toString()
    >
    > We use jdk1.3.1_03_b03 mixed mode ( Solaris)
    >
    > When we compile the same code on ( Linux) but with
    >
    > jdk1.3.1_11 I get no compilation error.
    >
    > Is it allowed to have major changes in the api even
    > if the the 1.3.1 is not changed? Or is this a bug in
    > the compiler?
    >
    > cheers,
    >
    > //mikael
    Alex Whitney, Jun 8, 2006
    #2
    1. Advertising

  3. Petterson Mikael

    Chris Uppal Guest

    Petterson Mikael wrote:

    > In a java source file we have the following:
    >
    > String value = Boolean.toString(succeed);
    >
    > When we compile we get:
    >
    > Cannot resolve symbol toString()
    >
    > We use jdk1.3.1_03_b03 mixed mode ( Solaris)


    That's correct -- Boolean.toString(boolean) didn't appear until JDK 1.4.


    > When we compile the same code on ( Linux) but with
    >
    > jdk1.3.1_11 I get no compilation error.


    I'll bet you aren't really compiling with a 1.3 compiler.

    Try doing

    type javac

    to find which compiler executable you are running, and

    javac -version

    to see what version it thinks it is (NB: that's java/C/ -version).

    -- chris
    Chris Uppal, Jun 8, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ELJ
    Replies:
    2
    Views:
    562
    Paulo Valentim
    Feb 25, 2005
  2. Dan
    Replies:
    3
    Views:
    597
    =?Utf-8?B?RGFu?=
    Jun 14, 2004
  3. JSR
    Replies:
    2
    Views:
    358
  4. bcassand
    Replies:
    4
    Views:
    1,478
    Martin Moessner
    Jan 12, 2004
  5. C__chp
    Replies:
    4
    Views:
    503
    Puppet_Sock
    Feb 15, 2008
Loading...

Share This Page