Featured
-
How to split a String
Below I have written a code to split a string.
by shahbaz.ahmmod -
Send Push Notification with Custom Data to iPhone device from Java Server Side
This blog will help you to send Push Notifications
by babita.dhami -
Tomcat and Eclipse Integration Error : “Unknown version of Tomcat was specified”
If you are adding Server in Eclipse for Tomcat, an
by chandan.ahluwalia -
Spring MVC and MongoDB
Repository Class Using MongoDB : Spring has th
by sumit.vyas -
How to create DLL file from java?
Hello Guy's This Blog will guide how to create D
by bhagwan.khichar
Tags
How to Merge two array list
In the below example I have described "how to add or merge two array list?". Here I have created two array String a[],String b[], then I have initialize values in array . After this I have created arrayList and merge value S...
Wrapper Class
Wrapper Class:
In Java there are 8 primitive data types and to convert them into object we use wrapper classes. We use boxing and autoboxing to convert primitive into object and object into primitive.
Primitive type and their correspnding w...
How to split a string in Java?
Java String split
The java string split() method splits a string according a given regular expression and returns a char array.
There are two signature for split() method in java string.
public String split(String r...
Iterator in Java
Iterator in Java
java.util package has public interface Iterator. Iterator can be defined as interface which belongs to collection framework. Iterator as name suggest allows accessing,removing and traversing data eleme...
Comments that will execute in Java?
We know “Comments do not Execute” . Below is the code which shows “The comments that execute” in java.
public class Testing
{
public static void main(String[] args)
{
// the line below this...
Variable Arguments
Variable Arguments :
We can pass variable number of arguments to a function in Java. Variable arguments means passing different number of arguments to same function on different call. Variable number of arguments are represented by elipsis(......
Nested and Inner Class
Nested Class:
A class written inside another class is known as nested class, and the class that contains the inner class is called the outer class.
Nested class are of two types Static class and Non-static inner class. And non-static ...
Configure Profiles in a Maven Project
Hello Guys !
In this blog, we'll see how to configure the profiles in a Maven project. We might have different sensitive information that we need to maintain to different environments.
For example - A developer might have different serv...
Maven Run Configuration to run project within eclipse
In this example, we'll see how to configure Maven to run a project on tomcat withing eclipse. It is sometimes too hard to manage the Maven project with the commands. Each time we code the project in IDE like eclipse and go to the terminal/cmd...
Difference between ArrayList and LinkedList in Java ?
Difference between ArrayList and LinkedList in Java
ArrayList class and LinkedList class are classes of Java with following syntax:
ArrayList class Syntax:
ArrayList<String> al=new ArrayList<Strin...
Remote Method Invocation
RMI stands for Remote Method Invocation to create distributed application in java. In this object access to invoke method (goes to the machine to execute method and returns the result to the other machines). In RMI client invokes the method ...
PreparedStatement Interface
PreparedStatement interface:
It is used to execute a SQL parameterized query and it compiles only one time and we can use it many times. It extends the Statement interface. It is more secure then Statement interface and safely provid...
User Defined Exception
User Defined Exceptions:
In some situation a programmer needs to create and throw his own created exception and such type of exceptions are known as User defined Exception or Custom Exceptions.
To create own exceptions we have to Extend t...
Checked and Unchecked Exceptions
Checked Exceptions:
Checked Exceptions are those exceptions which are checked during compile time. If a program contains checked exception then it should be handled using try-catch block or by using throws keyword, otherwise there will be a co...
Autoboxing and Unboxing
What is Boxing and Unboxing?
There are various primitive data types in java such as byte, int, long. etc. We have wrapper classes corresponding to each of the data type in java.
Sometimes the values of primitive data types are needed ...
How to create executable JAR file with dependencies using Maven?
Using maven we can create executable JAR file with all the requires dependencies and then we can use that JAR file to execute the whole project. So, to create the JAR file just add the below plugin inside the build tag.
<plugin>
<...
Program to Detect and Remove Loop in a Linked List in Java?
// Program to detect and remove loop in linked list in java
class LinkedList //create a node in LinkedList
{
static Node head;
static class Node //create a node in LinkedList
{
int data;
Node ...
How to to use covariant return type in java
In the below example I will help you to use covariant return type in java. In covariant return will used overriding method. The covariant return type specifies the return type in the same direction as the subclass. Here in the below e...
ArrayList Class
ArrayList:
The arraylist class provides dynamic arrays for storing elements. It extends AbstractList class and implements List interface. It stores only one type of objects (generic array).
Syntax:
ArrayList<String> arr=new Array...
Difference between Singleton and Prototype bean
Singleton Bean Scope
The singleton bean is termed as a stateless bean i.e. it doesn't carry any state with it. Only one instance of the object is created which is defined by this type of bean. One instance is created per container.All the o...
How to swap or exchange objects in Java?
How to swap or exchange objects in Java?
Wrapper Class can be used to swap or exchange objects in Java.
A Java program using wrapper classes to swap objects.
class Employee
{
int empno, salary;
Car(int empno, int salary) //P...
To determine Infinity or Exception in Java
To determine Infinity or Exception in Java?
Consider two programs in Java:
Program 1:
public class Demo
{
public static void main(String[] args)
{
double a = 1;
System.out.println(a/0);
}
}
Output ...
Difference of String, StringBuilder and StringBuffer in Java?
Difference of String, StringBuilder and StringBuffer in Java?
String
1)String value are stored in dynamic memory (managed heap) and variables of type string keep a reference to an object in heap.
2)The character sequence stored in string...
To redirect System.out.println() output to a file in Java instead to console?
To redirect System.out.println() output to a file in Java instead to console?
The internal working of System.out.println():
System: java.lang package contains the class System with it's defination.
out: out is a public and static varia...
Directing System.out.println() output to a file instead to console in Java.
Directing System.out.println() output to a file instead to console in Java.
The internal working of System.out.println():
System: java.lang package contains the class System with it's definition.
out: out is a public and static varia...
Access Modifiers in Java
Access Modifiers:
Access Modifiers are used to provide access level and visibility to variables,classes and to methods. There are four access modifiers in Java.
Default
Private
Public
Protected
1. Default Access Modifier:
...
How to swap two variables in one line in Java?
How to swap two variables in one line in Java?
// Java program to swap two variables in single line
class Demo
{
public static void main (String[] args)
{
int a = 6, b = 11;
a = a ^ b ^ (b = a);
System.out.prin...
StringBuffer in Java
StringBuffer:
As we know in Java String is immutable means we cannot reassign a new value to the same string object. That's why in Java to provide mutability we use either StringBuffer or StringBuilder. StringBuffer is a class in Java which pr...
OVERRIDING IN JAVA
Overriding method is different than overloading, as in overloading of a method, their are more than one method with same name but different parameter with in same class unlike this, In overriding of a method, a method in child class(sub class) ha...
ACHIEVING ABSTRACTION BY INTERFACES IN JAVA
Abstraction is a concept which shows only important(essential) feature and hide background details. In other way, abstraction shows only those things to user which are important and hides the background details. In java we can achieve abstractio...
LITERAL IN JAVA
LITERAL IN JAVA
A literal is a value that may be
assigned to a primitive or string
variable or passed as an argument to
a method call.
Literals can be any thing like
number, text or other information
who represents a value.
Literals a...
OVERLOADING IN JAVA
In java we can define more than one method inside one class(same class), whose names are same until their parameters or signature are different. This process or method of having more than one method within same class with different parameters or ...
How to run a program without a main metod in JAVA?
First of all see the following program::
public class Hello{
static{
System.out.print("Hello! Running Java program without main method.")
System.exit(0);
}
}
The output of above program will be::
Hello! Run...
Steps to connect to the Oracle Database using JDBC in Java
Steps to connect to the database in java using JDBC for Oracle database
1) Driver class is registered
The driver class is registered first with the help of the forName() method.
e.g.
Class.forName("oracle.jdbc.driver.OracleDriver"); ...
ACHIEVING ABSTRACTION BY ABSTRACT CLASS IN JAVA
Abstraction
Abstraction is a concept which shows only important(essential) feature and hide background details.
In other way, abstraction shows only those things to user which are important and hides the background details.
for eg :- examp...
Interfaces in java
Interface:
Interface is similar to class and
represented by interface keyword. It
contain only pure abstract methods
means only declaration of methods is
given inside interface and the class
which implements it write the body
for that ...
Difference between call by value and call by reference in java
1) Call by value:
When you are passing values of primitive data types as arguments to the function , then a copy of the values is created and the changes which are done are reflected in the duplicate values and hence, the original values rem...
INHERITANCE IN JAVA
Inheritance is a process where sub class have same properties then its super class. In this process sub class acquire all the characteristics of its super class.
By using inheritance we can manage information in hierarchical manner.
The c...
Polymorphism: Overloading and Overriding
Polymorphism:
Polymorphism is one of the OOPs pillars. Polymorphism is the ability of a method to behave differently as per the object. Polymorphism allows programmer to declare a method and use it differently based on the instance.
In Java...
final, finally and finalize in Java
final, finally and finalize in Java
final:
The meaning of final keyword varies with it's usage with class,methods and variables.
Class: When final keyword is placed before class keyword then that class cannot be inherited i.e final class...
Assertion in java
Assertion:
Assertion is a statement used to test assumptions of the programmer about the program. While, executing assertion it is always true but in case , it fails, JVM will throw an error named AssertionError. Assertion is mainly used for t...
ServletConfig Interface in servlets
ServletConfig interface:
For each servlet, an instance of this interface is created by the container. With the help of this instance, information can be fetched from the configuration file (web.xml).
Advantage:
You don't need need t...
Session tracking in servlets by using HttpSession
HttpSession Interface
It is one of the session tracking techniques.
It basically creates a session for each user and is used to maintain the request data and time interval of a particular. A user may give more than one requests at a particul...
Difference between final,finally and finalize in java
1) Final:
Final is a keyword. It is used to store constant values in variable. The value can't be changed later on.
The class which is declared as final cannot be inherited.
The method which is declared as final cannot be overridden.
E...
Difference between Association and Aggregation
In object oriented programming Association and Aggregation shows the relationship between the classes. Relationship in OOPS defines the connection between the objects. It basically shows how objects are attached to each other and how they will op...
Why multiple inheritance is not possible in JAVA?
Inheritance
When one class acquires the functionality of some other class, it is called inheritance. i.e reusing the same properties and functions. The class which is inherited is known as the super class and the class which inherits the prop...
What are different types of scripting elements in jsp
JSP supports various programming language codes. With the help of scripting elements, you can write java code inside the jsp page.
There are three types of scripting elements which are really useful for inserting java code.
scriplet tag
...
Generics in Java
Java Generics
It has been observed that many programs or algorithms are same irrespective of data type they are applied to. To overcome this generics were added by JDK 5.Generics allows to define algorithms once which then can be applied to an...
Abstraction in java
Abstraction is defined as the hiding of backend content/details and only providing necessary information.
There are two ways to achieve abstraction:-
Abstract class
Interface
ABSTRACT CLASS:- The class which is declared as abstract is known...
Example of Oracle JDBC Connection
We have different database vendors out in the market and every vendor has different configuration for using their database. Here in this article we will talk about the getting connection of Oracle database using Jdbc.
For getting connection ...