Enviado em 05/04/2015 - 12:40h
Oi à todos.
Tenho o seguinte código:
public class PrimitiveParameters2
{
public int x=3;
public int y=4;
public PrimitiveParameters2(){
x=5;
y=6;
}
public static void main(String[] args)
{
go();
}
public static void go()
{
System.out.println("x=" + x + " y= " +y);
}
}
Está produzindo os seguinte erros:
PrimitiveParam.java:20: non-static variable x cannot be referenced from a static
context
System.out.println("x=" + x + " y= " +y);
^
PrimitiveParam.java:20: non-static variable y cannot be referenced from a static
context
System.out.println("x=" + x + " y= " +y);
^
2 errors
Já tentei colocar a variável como private tambem não funciona, o que será?
Tenho o seguinte código:
public class PrimitiveParameters2
{
public int x=3;
public int y=4;
public PrimitiveParameters2(){
x=5;
y=6;
}
public static void main(String[] args)
{
go();
}
public static void go()
{
System.out.println("x=" + x + " y= " +y);
}
}
Está produzindo os seguinte erros:
PrimitiveParam.java:20: non-static variable x cannot be referenced from a static
context
System.out.println("x=" + x + " y= " +y);
^
PrimitiveParam.java:20: non-static variable y cannot be referenced from a static
context
System.out.println("x=" + x + " y= " +y);
^
2 errors
Já tentei colocar a variável como private tambem não funciona, o que será?