Created
June 20, 2017 22:00
-
-
Save Slagrach/9d0644d3885837c7b9a352b85709b7a8 to your computer and use it in GitHub Desktop.
MyClass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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