INTRODUCTION TO JAVA PROGRAMMING
JAVA
The Java programming language is a high-level, object-oriented and general-purpose computer programming language.
Java is similar to C++, but simplified to eliminate language features that cause common programming errors.
Where's Developed
Java was developed by Sun Microsystems in the early-to-mid 1990s, and development continues to this day, of course.
A team headed by James Gosling is set up to work on a programming language for consumer electronic devices.
The goals were to develop a small langauage, that would easily adapt to new chips, and be very reliable. The language was originally known as Oak, but that name was already used, so it had to be changed.
Features
Simple
Secure
Portable
Object-oriented
Robust
Multithreaded
Architecture-neutral
Interpreted
High performance
Distributed
Dynamic
Rules
It
Case Sensitivity
Java is case sensitive, which means identifier Hello and hello would have different meaning in Java.
Class
For all class names the first letter should be in Upper Case
Myclassname()
Method
For all method names the first letter should be in lower Case
myMethodname()
Classes and methods (including other flow-control structures) are always defined in blocks of code enclosed by curly braces { }.
All other statements are terminated with a semi-colon (;).
File name
Name of the program file should exactly match the class name
Example : Assume 'DineshClass' is the class name. Then the file should be saved as 'DineshClass.java'.
Main method
public static void main(String args[])
Java program processing starts from the main() method which is a mandatory part of every Java program.
Hello World Program
File name : HelloWorld.java
class HelloWorld
{
public static void main(String args[]) {
System.out.println("Hello, World!");
}
}
Output : Hello, World!
System.out.println() to display text to the terminal.
Key Words
Keywords are special tokens in the language which have reserved use in the language. Keywords may not be used as identifiers in Java.You cannot declare a field whose name is a keyword, for instance.
- abstract
- assert
- boolean
- break
- byte
- case
- catch
- char
- class
- const
- continue
- default
- do
- double
- else
- enum
- extends
- final
- finally
- float
- for
- goto
- if
- implements
- import
- instanceof
- int
- interface
- long
- native
- new
- package
- private
- protected
- public
- return
- short
- static
- strictfp
- super
- switch
- synchronized
- this
- throw
- throws
- transient
- try
- void
- volatile
- while
Comments
Post a Comment