Compilation problem

  • Thread starter Petterson Mikael
  • Start date
P

Petterson Mikael

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
 
A

Alex Whitney

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);
 
C

Chris Uppal

Petterson said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top