| Small code segment which will show you how you can establish
connection with oracle and insert some values in database Table. |
import java.io.*;
import java.sql.*;
public class AddRecord
{
public static void main(String[] args)
{
try
{
Connection con=null;
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection(
"jdbc:oracle:thin:@machine_name:1521:database_name", "scott", "tiger");
Statement s= con.createStatement();
s.execute(" INSERT INTO BOOKS VALUES ( 'Java Programming', 'Dr. Abdullah',
3333323, '6-jan-2005' ) ");
s.close();
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
|
|
|
| How you can get
IP Address of the Host (local System computer) using Java |
class getlocalip
{
public static void main (String args[])
{
try {
String s=java.net.InetAddress.getLocalHost().getHostAddress();
System.out.println(s);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
|
|
| Input - Output - Variables |
| A Java Program to print a
string on the Standard Output Device.
|
| A Java Program to declare
and initialize Integer variables and print them on the Standard Output Device.
|
| A Java Program to show the
use of Increment and Decrement Operators. |
| A Java Program to read
input from the Standard Input Device. |
| A Java Program to declare
and initialize Boolean variables and print them on the Standard Output Device |
| A Java Program to print
some text on the same line using multiple print statements. |
| Bitwise Operators |
| A Java Program to show the
use of Bitwise Operator (&) AND.
|
| A Java Program to show the
use of Bitwise Operator (|) OR.
|
| A Java Program to show the
use of Bitwise Operator (^) XOR (Exclusive OR).
|
| A Java Program to show the
use of Bitwise Operator (~) Complement
|
| A Java Program to show the
use of operator (<<) Shift Left filling with zero from the right.
|
| A Java Program to show the
use of operator (>>) Shift Right, propagating the sign bit from the left.
|
| A Java Program to show the
use of operator (>>>) Shift Right, filling with zeros from the left.
|
| Conditional Statements - Logical
Operators |
| A Java Program to show the
use of If Statement.
|
| A Java Program to show the
use of If-Else Statement.
|
| A Java Program to show the
use of Nested If-Else Statements.
|
| A Java Program to show the
use of Conditional AND Operator (&&) in If Statements.
|
| A Java Program to show the
use of Logical AND Operator (&) in If Statements
|
| A Java Program to show the
use of Conditional OR Operator (||) in If Statements |
| A Java Program to show the
use of Logical OR Operator (|) in If Statements. |
| A Java Program to show the
use of Conditional (Ternary) Operator. |
| A Java Program to show the
use of Switch Statement. |
| A Java Program to show the use of Switch Statement
for the same statement for different case labels. |
| Loops - The Continue/Break Statement |
| A Java Program to show the use of For Loop.
|
| A Java Program to show the use of While Loop.
|
| A Java Program to show the use of Do-While Loop.
|
| A Java Program to show the use of Nested Loops
|
| A Java Program to show the use of Continue Statement
|
| A Java Program to show the use of Labeled Continue
Statement.
|
| A Java Program to show the use of Break Statement.
|
| A Java Program to show the use of Labeled Break
Statement.
|
| Arrays |
| A Java Program to declare, initialize and print an
array of integers |
| A Java Program to copy the elements of an array into
another array in reverse order and print them |
| A Java Program to sort the contents of an array
using Bubble Sort. |
| A Java Program to search an element in an array
using Linear Search. |
| A Java Program to declare, initialize and print an
array of characters |
| A Java Program to declare, initialize and print a 2D
array of integers. |
| A Java Program to calculate the addition of two
matrices using 2D arrays of type float. |
| Strings |
| A Java Program to declare, initialize and print a
String object |
| A Java Program to show an example of Arrays of
String |
| A Java Program to show an example of Concatination
of Strings |
| A Java Program to show the use of Comparison
operator (==) for comparing Strings. |
| A Java Program to show the comparing of Strings for
equality. |
| A Java Program to check the start and end of a
String. |
| A Java Program to compare Strings by compring
successive corresponding characters, starting with the first character in each
String. |
| A Java Program to show an example of getting at
characters in a String |
| A Java Program to show an example of searching
Strings for characters |
| A Java Program to show an example of searching
Strings for subStrings |
| A Java Program to show an example of extracting
subStrings from a String. |
| A Java Program to show an example of modifying
String objects. |
| A Java Program to show an example of creating
Character Arrays from String objects |
| Java Program to show an example of creating String
objects from Character Arrays. |
| StringBuffer |
| A Java Program to declare, initialize and print a
StringBuffer object. |
| A Java Program to show some properties of
StringBuffer object |
| A Java Program to append a StringBuffer by
StringBuffer, String objects and other Basic Data Types. |
| A Java Program to show insertion of StringBuffer,
String objects and other Basic Data Types into a StringBuffer object.
|
| A Java Program to show an example of extraction of
characters from a StringBuffer objects
|
| A Java Program to change characters in a
StringBuffer objects and to reverse its contents
|
| A Java Program to show an example of creating a
String object from a StringBuffer Object.
|
| Classes |
| Java Program to show an example of creating a class
and using its object.
|
| A Java Program to show an example of using
initialization block to initialize the data members of a class
|
| A Java Program to show an example of using
constructors in a class to initialize its data members.
|
| A Java Program to show an example of overloading
constructors in a class to initialize its data members.
|
| A Java Program to show an example of using multiple
classes in a program.
|
| A Java Program to show an example of using a
recursive method in a class
|
| A Java Program to show an example of using
user-defined package in a program
|
| A Java Program to show an example of using a Static
Nested Class.
|
| A Java Program to show an example of using a
Non-Static Nested Class
|
| A Java Program to show an example of using a Static
Nested Class outside the Top-Level Class.
|
| Extending Classes and Inheritance |
| A Java Program to show an example of Driving and
using a Class |
| A Java Program to show an example of Overriding a
Base Class Method.
|
| A Java Program to show an example of Calling a Base
Class Method from a Derived Class.
|
| A Java Program to show an example of Polymorphism
|
| A Java Program to show an example of Multiple Levels
of Inheritance.
|
| A Java Program to show an example of using Abstract
Class and Abstract Method.
|
| A Java Program to show an example of Copying Objects
i.e. Clonning Objects.
|
| Standard Libraray Class Methods |
| A Java Program to show the use of some Math Methods. |
| A Java Program to show the use of some Character
Methods. |
|