Tuesday, December 4, 2007
Prime Number Program : Java Programming
import java.io.*;
class PrimeNumber {
public static void main(String[] args) throws Exception{
int i;
BufferedReader bf = new BufferedReader(
new InputStreamReader(System.in));
System.out.println("Enter number to Check:");
int num = Integer.parseInt(bf.readLine());
System.out.println("Prime number: ");
for (i=1; i < num; i++ ){
int j;
for (j=2; j<i; j++){
int n = i%j;
if (n==0){
break;
}
}
if(i == j){
System.out.print(" "+i);
}
}
}
}
Thursday, November 29, 2007
Explanation : public static void main(String args[])
- public : The public method can be accessed outside the class
- static : We must have an instance to access the class method.
- void : There is no need by application to return value. JVM launcher do this with it exists.
- main() : It is the entry point for the java application.
- String args[] : It holds optional arguments passed to the class.
Tuesday, November 27, 2007
First Program in Java
class HelloWorld {
public static void main(String[] args){
System.out.println("My First Program:Hello World!");
}
Thursday, November 22, 2007
Introduction : Java Programming
Java Language :
It is high-level object-oriented programming language developed by Sun Microsystems in 1995. It is very similar to C++. It was used for the project set top box, was created by James Gosling in 1991. It is the modified from the language Oak. Oak was unsuccessful in the market. So Sun modified this language and changed its name to Java.It is very one of the popular programming language because of platform independent nature and used in both computer and electronic devices. Platform independent means write once and run anywhere, only Java Virtual Machine needed to run Java program on any platform.
Labels:
Introduction to Java,
Java Definition,
Java Language
Subscribe to:
Posts (Atom)