Skip to main content
IBM 
ShopSupportDownloads
IBM HomeProductsConsultingIndustriesNewsAbout IBM
Java Language EssentialsDownload tutorial zip fileEmail this tutorial to a friend
Main menuSection menuGive feedback on this tutorialPrevious panelNext panel
Course Notes
  


User-defined data types page 2 of 37


With the Java(TM) programming language, every computer program must define one or more user-defined data types via the class construct. For example, to create a program that behaves like a dog, we can define a class that (minimally) represents a dog:


class Dog {
  void bark() {
    System.out.println("Woof.");
  }
}

This user-defined data type begins with the keyword class, followed by the name for the data type, in this case, Dog, followed by the specification of what it is to be a dog between opening and closing curly brackets. This simple example provides no data fields, only the single behavior of barking, as represented by the method bark().


copyright 1996-2000 Magelang Institute dba jGuru


Main menuSection menuGive feedback on this tutorialPrevious panelNext panel
PrivacyLegalContact