Skip to content

Instantly share code, notes, and snippets.

View kenorb's full-sized avatar
💭
The Consciousness Has Shifted...The Awakening Has Begun

Rafal W. kenorb

💭
The Consciousness Has Shifted...The Awakening Has Begun
View GitHub Profile
@kenorb
kenorb / StringDemo.java
Last active August 29, 2015 14:04
String Handling Demo
/*
* StringDemo.java
*
* String Handling.
* - String is fixed and immutable class object.
* - Strings are stored in Java heap memory.
* -
*
* Usage:
* javac StringDemo.java && java StringDemo
@kenorb
kenorb / StringBufferDemo.java
Last active August 29, 2015 14:04
StringBuffer class Demo.
/*
* StringBufferDemo.java
*
* StringBuffer class Demo.
*
* A thread-safe, mutable sequence of characters.
* A string buffer is like a String, but can be modified.
* At any point in time it contains some particular sequence of characters,
* but the length and content of the sequence can be changed through certain method calls.
*
/*
* ExceptionDemo.java
*
* A process of responding to the occurrence, during computation
* – anomalous or exceptional events requiring special processing.
*
* Clauses of Exception Handling
* 1. try
* Program statements which raised exception should be returning try block.
* 2. catch
@kenorb
kenorb / Excep1.java
Last active August 29, 2015 14:04
ArithmeticException Demo
/*
* ArithmeticException Demo
*
* Notes:
* - A try block can have one or more catch blocks, or finally block.
*
* Usage:
* javac Excep1.java
* java Excep1
* java Excep1 10 2
@kenorb
kenorb / UserExceptionDemo.java
Last active August 29, 2015 14:04
User Defined Exception Demo
/*
* User Defined Exception Demo
*
* 1. Create a class by extending Exception class
* 2. Write a parameterized constructor.
* 3. Override the toString() method.
*
* Usage:
* javac UserExceptionDemo.java
* java UserExceptionDemo 2 10
@kenorb
kenorb / UnreportedExceptionDemo.java
Created July 23, 2014 18:36
UnreportedException Demo
/*
* UnreportedException Demo
*
* Usage:
* javac UnreportedExceptionDemo.java
* java UnreportedExceptionDemo
*/
class UnreportedExceptionDemo {
public static void main(String[] args) throws ClassNotFoundException {
// public static void main(String[] args) { // error: unreported exception ClassNotFoundException; must be caught or declared to be thrown
@kenorb
kenorb / FileHandlingDemo.java
Last active August 29, 2015 14:04
File Handling Demo
/*
* File Handling Demo
*
* Is all about reading and writing activities over file system (java.io).
* Streams provide communication channels between communication participants.
*
* Type of stream classes:
* * Byte Stream classes:
* - do not support Unicode
* * Character Stream classes:
@kenorb
kenorb / SerializationDemo.java
Last active August 29, 2015 14:04
Serialization Demo
/*
* Serialization Demo
*
* Serialization is a process of writing a state of an object to a ByteString.
* Deserialization is a process of reading state of an object from a file.
*
* Notes:
* - Only objects of class which implements the serializable interface can be serialized.
*
* Usage:
@kenorb
kenorb / Jdbc1.java
Last active August 29, 2015 14:04
JDBC API Demo
/*
* JDBC API Demo
*
* JDBC (Java Database Connectivity API) provides several classes and interfaces
* that enables java applications to communicate with the backend system.
*
* JDBC Architecture
* Java Application -> Driver Manager -> Available drivers (MySQL Driver, Oracle, SQL Server).
*
* All the java applications should follow the standard steps such as:
@kenorb
kenorb / Jdbc2.java
Last active August 29, 2015 14:04
JDBC API Demo 2
/*
* JDBC API Demo 2
*
* PreparedStatement is pre-compiled statement and activites include:
* - load the query
* - parse the query
* - execute the query
* - save the query
*
* Usage: