Friday 10, February 2012
Welcome Guest, Register | Login  
      Home    |    Tutorials    |    Free Ebooks    |    Free Scripts    |    Articles    |    Blog     |    Forum    |    About Us    |    Contact Us

Java Classes

Classes are the fundamental building blocks of a Java program. You can define an Employee class as follows:
class Employee {
  int age;

  double salary;
}

  1. By convention, class names capitalize the initial of each word.
  2. For example: Employee, Boss, DateUtility, PostOffice, RegularRateCalculator.
  3. This type of naming convention is known as Pascal naming convention.
  4. The other convention, the camel naming convention, capitalize the initial of each word, except the first word.
  5. Method and field names use the camel naming convention.

A Simple Class Definition

class Count {
    public static void main(String args[])
        throws java.io.IOException
    {
        int count = 0;
        while (System.in.read() != -1)
            count++;
        System.out.println("Input has " + count + " chars.");
    }
}

In the Java language, all methods and variables must exist within a class. So, the first line of the character-counting application defines a class, Count, that defines the methods, variables, and any other classes needed to implement the character-counting application. Since this program is such a simple one, the Count class just defines one method named main().

 
     
   
Java Language Tutorial
 
  What is JAVA
What is JAVA
  Java an Object Oriented Language
Java an Object Oriented Language
  Java Keywords
Java Keywords
  Data Types
Data Types
  Java Operators
Java Operators
  Control Structure
Control Structure
  Arrays
Arrays
  Java Classes
Java Classes
  Java Constructors
Java Constructors
  Java Methods
Java Methods
  Java Method Overloading
Java Method Overloading
  Java Method Overriding
Java Method Overriding
  Java Nested Classes
Java Nested Classes
  Inheritance in Java
Inheritance in Java
  Interfaces in Java
Interfaces in Java
  Polymorphism in Java
Polymorphism in Java
  Exception Handling in Java
Exception Handling in Java
  Catching Exceptions
Catching Exceptions
  Embedding information in an exception object
Embedding information in an exception object
  The throws clause
The throws clause
  Checked and unchecked exceptions
Checked and unchecked exceptions
  The finally clause
The finally clause
  Applets in Java
Applets in Java
  Running an Applet
Running an Applet
 
 
 
Web Designing Tutorials
  HTML Tutorial
HTML Tutorial
  DHTML Tutorial
DHTML  Tutorial
  CSS Tutorial
CSS Tutorial
  XHTML Tutorial
XHTML Tutorial
 
Programming Languages Tutorials
  C Language Tutorial
C Language Tutorial
  C++ Tutorial
C++ Tutorial
  Java Language Tutorial
Java Language Tutorial
  Data Structure Theory Tutorial
Data Structure Theory Tutorial
 
Server Side Scripting Tutorials
  PHP Tutorial
PHP Tutorial
  SQL Tutorial
SQL Tutorial
  ASP Tutorial
ASP Tutorial
 
Client Side Scripting Tutorials
  JavaScript Tutorial
JavaScript Tutorial
  VBScript Tutorial
VBScript Tutorial
 
 
 
POPULAR E-BOOKS
 
Download Excerpts from the Abstract Ebook Excerpts from the Abstract
   
Download SEO  Search Engine Optimization Made Easy Ebook SEO Search Engine Optimization Made Easy
   
Download Market Yourself Professionally  Ebook Market Yourself Professionally
   
Download Affiliate Marketers Handbook  Ebook Affiliate Marketers Handbook
   
Download Data Structures and Algorithms With Object-Oriented Design Patterns in Java  Ebook Data Structures and Algorithms With Object-Oriented Design Patterns in Java
   
 
Studiesinn.com © 2012 All Rights Reserved.
Website Designed & Developed by TechXprtz