Thursday, June 02, 2005

Classes

Classes are the blueprints that describes objects. See Object-oriented programming

You can write your own classes easily like this:

package animalfarm;

class Dog {
}

public class Main {
   public static void main(String[] args) {
   }
}

This is the code for the Dog class: class Dog { }. Uh, oh, the name of the package is borrowed from Orwell (1945). Let's write some more classes!

package animalfarm;

class Pig {   
}

class Dog {
}

class Chicken {
}

class Pigeon {   
}

class Sheep {   
}

public class Main {
   public static void main(String[] args) {
   }
}

That's pretty easy, right!

References

http://en.wiktionary.org/wiki/Category:Animal_sounds

No comments: