This is the code for Animal:
public class Animal
{
Cow moo = new Cow();
Pig oink = new Pig();
public static void main(String[] args)
{
new Animal();
}
public Animal()
{
System.out.println("Pig " + oink.getName() + " and " +
"Cow " + moo.getName());
}
}
This is the code for Cow:
public class Cow
{
String name = "";
public void moo()
{
new Cow();
}
public void name()
{
String name = "Cow";
}
public String getName()
{
return name;
}
}
This is the Pig code:
public class Pig
{
String name = "";
Animal group = new Animal();
public void oink()
{
new Pig();
System.out.println(group.getName());
}
public void name()
{
String name = "Pig";
}
public String getName()
{
return name;
}
}
I have even tried extending the Animal class with either Pig or Cow and I still get the error code 'infinate stackcounter overflow'. Can anyone explain what I'm coding wrong and get me on the right track?
This post has been edited by gm5660: 09 October 2009 - 10:26 PM

New Topic/Question
Reply




MultiQuote




|