silly question
hello, i have a question,
as you konw "drawString" method. when I write the method as" g.drawString (example,25,25)" it gave me error message as can not resolve smybol. however if i changed it to "g.drawString("example"+example,25,25) it works. can I ask what is the different between them?
hope i explain it clear
> hello, i have a question,
> as you konw "drawString" method. when I write the
> method as" g.drawString (example,25,25)" it gave me
> error message as can not resolve smybol. however if
> i changed it to
> "g.drawString("example"+example,25,25) it works. can
> I ask what is the different between them?
drawString takes a String for its first arg, I guess. Your example variable is not a String.
If you read the whole error message, you'll see that the symbol that doesn't exist is the method you're trying to call--a drawString that takes whatever type your example variable is.
Learn to read error messages fully and carefully.
On the other hand, whenever you some string + something, a String is created from the something (by String.valueOf, I think) and added to the other string.
You can make the first one work by using String.valueOf(example) instead of just example.
jverda at 2007-7-29 18:00:19 >

> the word" example" I have declare it as "double" ,
> does it matter?
Depends what you mean.
It matters to the compiler that you're passing a double where it expects a String. That's why you get the error.
It doesn't matter to my explanation as to why you see the behvaior your do. The behavior would be the same and my explanation would hold for any non-String type that you declare example to be.
jverda at 2007-7-29 18:00:19 >
