faça: public class classe { static Integer i = new Integer(5);
public static void main(String args[]) { System.out.println(i.getClass()); } } OU: public class classe { Integer i = new Integer(5); public static void main(String args[]) { new classe(); } public classe() { System.out.println(i.getClass()); } }
From: "Vitor Brasileiro" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: <[EMAIL PROTECTED]>,<[EMAIL PROTECTED]>,<[EMAIL PROTECTED]>,<[EMAIL PROTECTED]>
Subject: [java-list] Problema de Iniciante
Date: Fri, 6 Dec 2002 16:15:09 -0200
To com um problema nessa classe, o erro é classe.java:5: non-static variable i cannot be referenced from a static context System.out.println(i.getClass());
a classe é:
public class classe {
Integer i = new Integer(5);
public static void main(String args[]) {
System.out.println(i.getClass());
}
}
O JBuilder 7.0 nao deixa remover o "static" do main, mas o textpad deixa. Tem como configurar isso?
[]
Vitor
_________________________________________________________________
MSN Hotmail, o maior webmail do Brasil. http://www.hotmail.com
------------------------------ LISTA SOUJAVA ---------------------------- http://www.soujava.org.br - Sociedade de Usuários Java da Sucesu-SP dúvidas mais comuns: http://www.soujava.org.br/faq.htm
regras da lista: http://www.soujava.org.br/regras.htm
historico: http://www.mail-archive.com/java-list%40soujava.org.br
para sair da lista: envie email para [EMAIL PROTECTED] -------------------------------------------------------------------------