Java is a general-purpose computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible. It is intended to let application developers “write once, run anywhere” (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation.-wikipedia
To learn Java Programming first you must know the how java programming works and how to write,compile and execute java programs.
Working of java Programs:
Java is computer programming language as other programming languages such as c,c++ bt what makes it diffierent from other is its javas byte code.byte code is nothing but patform independet code generated by jvm(java virtual machine).we can run this bye code on any device.When we compile any file .class file is generated by jvm for that computer.Now lets see the Structure of java File.
General Structure of java File:
public static void main(String args)
How to write java code:
important rules to consider while writing java code.
- File name and main class name has to be same.
- There can be one public class per source file .
- If there is any package need to be used package has to be the first statement.
- Import statement must be between package statement and the class statement.
Before you use java programming commands to compile,run java programs you must set path for java.To learn how to set path in java read this article how to set path in java
How to compile java Programming code.
javac command is used to invoke java compiler.general structure for javac command is
javac [options] [source file ]
javac -help // for help
javac program.java //for compiling
when you compile any java file you will get .class file for it.
How to execute (run) java program:
java command is used to invoke JVM. Here is structure of java command
java [options] [file name] [args if any]
java program //program is file name
java program 123 //123 is pass to args array
To lean how to run java applet read this article how run applet in command prompt.Beginers should use cmd to learn java programming once you get comfortable with it start using advance tools like net-beans and eclips
Simple java programs to learn java
- java program for prime number
- java program to Convert string to int
- java program to remove specific character from string in java
- java program to Swap values of two variables without using third variable
- java program for Fibonacci series
- java program to check palindrome
- java program to check armstrong number
- java program for pascal triangle
- java program for Merge Sort
- java program for Heap Sort
- java program for insertion Sort
- java program for Quick Sort
- java program for Selection Sort
- java program for Bubble Sort
- java program for Binary search
- java program for Linear search