We can develop two types of Java
Programmes
- Stand –alone applications
- Web applets
Stand –alone applications
An application is a normal
program which is executed as a normal
programme (Can’t run on the web browsers)
Executing stand-alone Java
program involves two steps
Compiling source code into byte code using java
compiler
Executing
the byte code program using java interpreter
Web applets
An applet is a tiny applications
that is executed in the world wide web
on the internet. To run it should first
be attached to a web page using HTML. An
applet located on a distant computer can be downloaded via internet and
executed on a local computer using a java
capable browser. We can develop applet
for doing everything form simple
animated graphics to complex games and utilities.
Simple Java Programme
public class HelloWorld
{
Public
static void main(string args[])
{
System.out.println (“Hello World”);
}
}
- Name of the class is Student. The keyword public tells that it can be accesses from other classes.
- Open brace bracket and close brace bracket indicate the beginning and end of the class { }
- Student class has only one method. It is called main(). Main() is like a main programe. It is a class method meaning that it works on the class it self rather than on the objects. The keyword static tells this.
- The main () has one incoming parameter an array object called arg[] belong into string type. It accepts command line arguments.
- The keyword void says that the method does not return any values
- System.out.println is a command which displays something on the screen
No comments:
Post a Comment