Re: Trying to learn methods.
That's not an error. That's a String representation of an Object that has not overridden the toString() method. Think about it this way: how does Java know how to display an Object as a String? It doesn't, unless you tell it how to by overriding the toString() method.
Re: Trying to learn methods.
int minvärde,maxvärde,startvärde;
And never ever use Umlauts in java code!
Re: Trying to learn methods.
Quote:
Originally Posted by
PhHein
int minvärde,maxvärde,startvärde;
And never ever use Umlauts in java code!
Why not?
It's perfectly legal, and seems unecessarily Anglo-centric to bar them?
Re: Trying to learn methods.
I've have heard reports about strange effects. It's generally advised here in Germany not to do it. Something about different default system encodings on servers and developer systems, if I recall corretly.
Re: Trying to learn methods.
System encodings should have no effect on variables in Java code, as it should all be UTF.
I can see something when dealing with Strings that contain non-ASCII, but that's character encoding and nothing to do with Java and the compiler.
Re: Trying to learn methods.
I prefer a random combination of Cyrilic, Chinese and Arabic characters (and umlauts) just to poke fun at those ASCII-centric pommies and for obfuscation reasons ...
kind regards,
乔斯
Re: Trying to learn methods.
I would laugh if it turns out that means something rude...
Sadly you managed to spell Jos, unless Google translate is pulling a fast one.
I live in hope.
Re: Trying to learn methods.
Quote:
Originally Posted by
Tolls
I would laugh if it turns out that means something rude...
Sadly you managed to spell Jos, unless Google translate is pulling a fast one.
I live in hope.
You know me, I am not like that; or as we always use to say: 哦,你必须是一个愚蠢的英语猪狗,我扭动我的生殖器您对我们厂总的方向
kindest regards,
Jos ;-)
Re: Trying to learn methods.
Quote:
Originally Posted by
KevinWorkman
That's not an error. That's a String representation of an Object that has not overridden the toString() method. Think about it this way: how does Java know how to display an Object as a String? It doesn't, unless you tell it how to by overriding the toString() method.
I see, the way i did it was this:
Code:
@Override
public String toString()
{
String resultat = Integer.toString(startvärde);
return resultat;
}
I suppose this is the only solution? Since as you said java does not know how to display an object as a string.
Re: Trying to learn methods.
Quote:
Originally Posted by
lekimo
I see, the way i did it was this:
Code:
@Override
public String toString()
{
String resultat = Integer.toString(startvärde);
return resultat;
}
I suppose this is the only solution? Since as you said java does not know how to display an object as a string.
Did that work?
I wouldn't say it's the only solution. You could have written another method and called that, or created a method that takes a calc (which should be Calc, by the way) Object and returns a String, or... the options are endless. But since you were already calling the toString() method, it does make sense to specify what that method should do.