Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Javatutorial Java basics

Related Tutorials


 
 

Share on Google+Share on Google+

Java basics

Advertisement
Java Basics are necessary to learn by programmers who are willing to learn Java language. These basics must be followed every-time a program is made in Java. Java language is completely specified that helps the programmer in making codes quickly. Java class library is available on any machine with a Java run-time system. Java language is secure. Java language is robust that means it is designed to avoid crashes.

Java Basics are necessary to learn by programmers who are willing to learn Java language. These basics must be followed every-time a program is made in Java.

Java language is completely specified that helps the programmer in making codes quickly. All data-type sizes and formats are already defined. Java class library is available on any machine with a Java runtime system. Java language is secure. Java language is robust that means it is designed to avoid crashes.

While writing Java programs, a programmer must keep following points in mind:

  • Java is case sensitive
  • The first letter of all class names must be in Upper Case.
  • If two or words are used to form a class name, first letter of each inner word must be in Upper Case. (ex.JavaClassName)
  • All method names must start with Lower Case letter.
  • If two or words are used to form a method name, first letter of each inner word must be in Upper Case. (ex. int MethodName())
  • Class name and Program File Name must be similar.
  • While saving file .java must be appended at then end. File name should also be similar to class name. (ex. If class name is JavaProgram than file name should be JavaProgram.java)

Following are the Java keywords that are used in methods:

  • abstract
  • default
  • if
  • private
  • this
  • boolean
  • do
  • implements
  • protected
  • throw
  • break
  • double
  • import
  • public
  • throws
  • byte
  • else
  • instanceof
  • return
  • transient
  • case
  • extends
  • int
  • short
  • try
  • catch
  • final
  • interface
  • static
  • void
  • char
  • finally
  • long
  • strictfp
  • volatile
  • class
  • float
  • native
  • super
  • while
  • const
  • for
  • new
  • switch
  • continue
  • goto
  • package
  • synchronized

Data-types in Java are classified in two types:

  1. Primitive data types:
  • Int
  • Float
  • Char
  • Void
  • Boolean
  1. Non-primitive data types:
  • Classes
  • Interfaces
  • Arrays

Different types of Variables in Java:

  • Instance Variables
  • Class Variables
  • Local Variables
  • Parameters

Here is an example of a simple Java program:

public class HelloWord {

	public static void main(String[] args) {
		System.out.println("HelloWord");
	}
}

OutPut:-

HelloWord

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: May 1, 2013

Related Tutorials

Discuss: Java basics  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com