Affichage d'une chaîne en Java
Bonsoir,
Je veux savoir comment afficher une chaîne de caractère non static en java ?
parceque je reçoit un message d'erreur par le compiltaeur:
cannot make static reference to the non static field c(avec c:string non static)
Je veux savoir comment afficher une chaîne de caractère non static en java ?
parceque je reçoit un message d'erreur par le compiltaeur:
cannot make static reference to the non static field c(avec c:string non static)
Configuration: Windows XP Firefox 2.0.0.12
3 réponses
-
System.out.println(ma_chaine); non ?
Bonne chance -
voici la portion de code:
string c=getNom(this)
public String getNom(Object o)
{
Class c = o.getClass();
return c.getName();
}
System.out.println(c);
l'erreur:
cannot make static reference to the non static field c
merci pour l'aide. -
Il faut que ton objet c soit d'un type qui implémente une méthode toString. Si elle n'existe pas déjà il faut la créer.
Bonne chance