Mega Code Archive

 
Categories / Java Tutorial / Class Definition
 

Fields

Fields are variables. They can be primitives or references to objects. For example, the Employee class has two fields, age and salary. public class Employee{   int age;   int salary } Field names should follow the camel naming convention. The initial of each word in the field, except for the first word, is written with a capital letter. For example: age, maxAge, address, validAddress, numberOfRows.