JAVA



History of java:
Java was written by James Gosling along with two other persons Patrick and Mike.

JDK:
Java development kit.
Provides develop, compile, debug and run a java program.
Consists of compiler, application launcher and debugger.
Compiler converts java code into machine instructions.
Application launcher starts the application.
Debugger helps to debug the program.

JRE:
Java run time environment.
Contains JVM and java library.
JVM is platform dependent and runs the program and it uses the java library.

How to download and install JDK and JRE:
1. Check whether system has jdk or not.
2. Open the browser.
3.
4.
5. Downloaded file.
6. Run the .exe file.

7. 
8.
9.
10.
11. Copy the path from java folder.
12. Now copy the path and paste in control panel->Advance setting->Environmental variables.
13. Now Similarly paste the jre path to it.
14. Now check whether system has correctly installed javac or not.
Now setting path for jdk and jre is completed.

Variable initiation:
Used to hold value of data type.
Ex: int a=9;

Data types in java:
Which type of value a variable has and what type of mathematical, relational and logical operations can be applied without causing an error.

Boolean:
Represents one bit of value.
Has true and false.
Default is false.

Char:
Minimum value is '\u0000' or 0.
Maximum value is '\uffff'.
Default size is 2 bytes.

Byte:
Minimum value is -128 and Maximum value is 127.
Default size is 1 byte.

Short:
Range value is -32,768 to 32,767
Default size is 2 bytes.

Int:
Range is -2,147,483,648 to 2,147,483,647.
Default is 4 bytes.

Long:
Range is -2^63 to 2^ 63-1.
Default is 8 bytes.

Float:
Default is 4 bytes.

Double:
Default is 8 bytes.

Hello world program:

String manipulation:
Used to perform the basic operation like concatenation, comparing etc.

Concatenation:

Sub-string:

Starting index of string:

Last index of String:

Count the no of occurrence of sub-string in string:

Count the no of occurrence of sub-string and replace:

Loops:
Used to execute a statement multiple times with single statement.

For loop:
Needs to be executed at a specific time.
Syntax: for(initialization;condition;inc/dec)

While loop:
Repeatedly executes the statement as long as condition is true.
Syntax: while(condition){
                                              Statements;
                                              inc/dec;
                                      }

Do-while loop:
Executes the statement even if the condition fails.

Loop control statements:
Change execution from its normal sequence.

Break:
Used to terminate the program immediately without executing the remaining statements.

Continue:
Used to end the current loop iteration and return control to loop of statement.

Conditional execution:
A statement that controls the flow of execution on some condition.

If:
If the condition is true then it will execute the statements.
Syntax: if(condition){
                                    Statements;
                                }

If-else:
If the condition is true it will execute statement otherwise it will execute else statement.
Syntax: if(condition){
                                     Statement;
                                 }
            else{
                      Statement;
                   }

Else-if:
Syntax: if(condition){
                                   Statement;
                                }
               else if(condition){
                                            Statement;
                                          }
                 else {
                           Statement;
                         }

Method and calling method:
Collection of statements that used to perform an operation.

Mathematical functions:
Cbrt: Gives the cube root of a number.
Max: Gives the maximum value of a number.
Min: Gives the minimum value of a number.
Ceil: Returns the greater than or equal to number.
Floor: Returns the less than or equal to number.
Abs: Gives the positive value of a number.
Hypot: Returns the sqrt(x^2+y^2) of a value.
Sqrt: Returns the sqrt of a number.
Random: Returns greater than or equal to 0 and less than 1.
Round: Rounds the value to nearest number.


Taking input from user:

File Writing:

File Reading:

Reading second line from a file:

Graphic function:
Small application.
Internet based program written in java.

First non repeated character in string:

Permutation of String:

Print true if string contains no or not:

Adding numbers in String:

Pyramid:
How to download and install eclipse:

Downloading jdbc driver:

Adding JDBC driver to eclipse:

You Might Also Like