Search Java Tutorials

Custom Search

What You Will Want to Complete This Tutorial?

You must have at least 1st and 2nd pre-requirements to start the tute. Other requirements will require for last chapters only. These all are free to use and download!
  1. Java Development Kit Standard Edition (JDK / J2SE) Any Version(www.java.com)
  2. Any Text Editor (Note Pad quite enough or get Notepad++ from (http://notepad-plus.sourceforge.net)
  3. Java Run Time Environment (JRE) Any Version(www.java.com)
  4. Java Enterprise Edition (J2EE) for advanced developing (For last few chapters)(www.java.com)
  5. Java Wireless Toolkit for Mobile Application Development (For Mobile Application Development Chapters) (www.java.com)
  6. Tomcat Web Server to run Servlets. (www.tomcat.apache.org/)
Your operating system may be any version of Windows.
What will you learn (As a summary)?
  1. How to build console and windowed applications using Java
  2. How to build web page elements with Java Applets
  3. How to build Database Programs with Java
  4. How to build enterprise applications with Beans
  5. How to add Email functions to Java programs
  6. How to program smart devices (Phone, PDA etc…) with Java

Class Declaration

Class is the outer cover of your program. All methods, resources and others are inside the class.

Let’s look at the class definition we used in the First.java.

‘ { ‘ bracket opens a class and ‘}’ closes it. ‘public class First’ is the line defining a class named “First”.

‘public’ means the class you want to create can be accessible from anywhere. You may use “protected”, “private” later to restrict access to the class. This word is known as “Access Modifier”.

And then “class” is a keyword that signs compiler that you are defining a new class.

That is basic! Following is the real! You might not understand many of notations now. But you’ll later. Every thing in squire brackets are optional and others are keywords.

[accessModifier] [classModifiers] class ClassName [extends SuperClassName] [implements InterfaceList]

{

[classbody]

}

If you are very keen on this tuff class declaration; this is what it says:

[accessModifier] : ‘public’, ‘private’, or other access modifier

[classModifiers] : ‘abstract’ for example, says you can’t create objects using this class. That is another kind of restriction known as Moderation.

class ClassName : Key words we must add to class declaration.

[extends SuperClassName] : Your class become an extend of a supper class.

[implements InterfaceList] : Tells compiler it’s time to use some interfaces with the class, such as ActionListener to sence user clickings.

Java Class Naming Rules

There’re certain rules in java you want to concern when defining a class and known as Syntax of the language.

  1. A Class Name must begin with a letter of the alphabet (which includes any non-English letter, such as alpha), an underscore or a dollar sign.
  2. A Class Name can contain only letters, digits, underscores, or dollar signes.
  3. A Class Name cannot be a java programming language reserved keyword. (Such as ‘public’, ‘class’)
  4. A Class name cannot be one of the following values: “true”, “flase” or “null

Class Names are conventionally starts with capital letters as it is easy to distinguish class names from other names you used for various other components. And be careful Java is Case Sensitive!

No comments: