Skip to content

Instantly share code, notes, and snippets.

@Slagrach
Created June 20, 2017 22:00
Show Gist options
  • Save Slagrach/9d0644d3885837c7b9a352b85709b7a8 to your computer and use it in GitHub Desktop.
Save Slagrach/9d0644d3885837c7b9a352b85709b7a8 to your computer and use it in GitHub Desktop.
MyClass
class Dog {
String name;
public static void main (String[]args) {
Dog a = new Dog();
a.bark();
a.name = "Pif";
Dog[] myDog = new Dog[3];
myDog[0] = new Dog();
myDog[1] = new Dog();
myDog[2] = a;
myDog[0].name = "Musena";
myDog[1].name = "Nochka";
System.out.println("Name last dog - ");
System.out.println(myDog[2].name);
int x = 0;
while (x < myDog.length) {
myDog[x].bark();
x += 1;
}
}
public void bark() {
System.out.println(name + "speek Gav!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment