Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

Can we overload the main() method

Overloading Main method: Like any other methods, it is possible to overload the main method also in java. One thing needs to be keep in mind while overloading the main method that it should be called inside some other main method. Lets s...

Method Overloading in Java

METHOD OVERLOADING: Having more than one methods with the same in the same scope. i.e. class is known as method overloading. It is useful in increasing the readability of the program. If a user wants to perform some operation say multiplica...

Adding multipli core in spring with custom solr repository

Repository take solrtemplate to execute solr operations. Since we have multiple cores so we need to create multiple template and multiple repositories for each core. Following example explains it with 2 solr core Repository and custom imp...

How to make AJAX call in jQuery?

Sometimes we need to make AJAX call in our Web page. The purpose of AJAX call is that you want to get/submit data without refreshing your page or you want to submit your form by calling an API. We can do this very easily by using ajax() method of...

Check two Linked Lists are Identical or not

Program to demonstrate two Linked Lists are Identical or not. class LinkedList { Node head; // head of list /* Linked list Node*/ class Node { int data; Node next; Node(int d) { data = d; next = null; } } /* Re...

Statement interface

Statement interface: It provides methods to interact with database means using Statement interface we can execute SQL queries.The createStatement() is present in java.sql.Connection interface and it does not take any argument. To use Statem...

Solr Atomic update with incremental popularity

In solr we can create a field which can update as the related doc is searched by user. For that we need to add a field in schema.xml as: <field name="popularity" type="long" indexed="true" stored="true"/> In the below code we hav...

How to generate unique number for an email in JAVA?

Sometimes we need to generate a unique number for an emailId, for example when a user register then we need to generate a number by using that user can verify his EmailId. For this we can use SHA1 encoding method. Example - In the below method...

How to encode string using MD5 in Java?

Generally we need to encode the password in our Applications for security purpose and we can use MD5 for this purpose. Example - In the below method I'm encoding sting by using MD5 import java.security.MessageDigest; import java.secu...

How to sort ArrayList in Java?

Sometimes we want to sort a List based on some property. Suppose we have a List of UserModel and we want to sort List by firstName then we can do that easily by using Collections.sort() and Comparator interface. Example: In the below example I...

How to get year from a date in Java?

To get only year from a date you can use the below code. You can pass any date that you wan to change, I'm getting year from the date in the below example:    /** * Get year from Date * * @param createDate *...

How to get full date with time in Java?

To get the full date with time you can use the below code. You can pass any date that you wan to change, I'm getting date in full date format in the below example:     /** * Get full month day year format from Da...

String Comparison using equals() and equalsIgnoreCase():

equals() and equalsIgnoreCase(): Both are used to compare two strings for equality and both methods are of String class. equals() general form: boolean equals(Object str) It returns true if the invoking string and the string passed ...

How to identify whehter the zip file contains valid files or not?

Sometimes we need to find whehter the zip file contains valid files or not. Suppose you have a zip file which contains multiple file you want to upload that zip file only if it contains files having extension jpeg,jpg,png,gif,tiff only, so we can...

How to push values in array in jQuery?

Sometimes we need to insert valuse in an array, we can do this by using push() method of jQuery very easily. Example     <!doctype html> <html lang="en"> <head> <meta charset="utf-...

The Initializer Block in Java.

The Initializer Block in Java The initializer block in Java contains code which is executed whenever an instance of class is created therefore this block contains common part for various constructor of a class. The order in which constructor a...

Pagination using Hibernate Criteria

Hi friends ! I am writing this blog to guide you about pagination. Examples are written for MySQL and Hibernate framework to bring the data. This is not a limitation and you can use your own database and framework if you wish. The concept is almo...

Error loading class 'org.apache.solr.handler.dataimport.DataImportHandler'

After starting solr if you get the following error, that means you need to make some changes in solrconfig.xml(of the core in which error occurred).   Open the xml and correct the path for solr-dataimporthandler-.*\.jar as <l...

java.util.Random Class

java.util.Random Class: java.util.Random class is used to generate random numbers. As we know random numbers are very useful especially in game development. In java we can generate random numbers in two ways either using java.lang.Math.random(...

Error: javax.servlet.jsp.PageContext cannot be resolved to a type

Running a Maven web project in eclipse was giving errors on jsp pages: javax.servlet.jsp.PageContext cannot be resolved to a type javax.servlet.jsp.JspException cannot be resolved to a type The server was running fine, even the project w...

java.util.Scanner Class

java.util.Scanner Class: It is used to read input from keyboard. It breaks the input provided into tokens using a delimeter (Whitespace). It extends Object  class and implements Iterator & Closeable interface. To use Scanner class we ...

Java Reflection and java.lang.Class class

Java Reflection The run time behaviour of a class can be examined and modified at run time,this process is called java reflection. To examine and change the run time behaviour of a class  java.lang.Class is used which provides many m...

javap tool in Java

 javap tool  javap is a command which when used with a classname, disassembles that class file. This command displays fields,methods and constructors information which are present in the class file with which javap command is us...

Program of Autoboxing where boxing beats varargs.

varargs varangs is variable arguments. varangs as name suggest allows a method to have 0 or mutiple argument. Autoboxing Autoboxing is converting primitive data type into it's equivalent wrapper type class automatically in Java....

Program of Autoboxing where widening beats varargs

Widening Widening in Java can be defined as converting a variable of a particular type into wider type. E.g: short is converted int primitive type. varargs varangs is variable arguments. varangs as name suggest allows a method ...

Program of Autoboxing where widening beats boxing.

Autoboxing Autoboxing is converts primitive data type into it's equivalent wrapper type class automatically in Java. E.g: int primitive type is converted to Integer Wrapper class in autoboxing. Widening Widening in Java can be define...

Autoboxing and Unboxing in Java

Autoboxing Autoboxing is a feature introduced in Java 5 and can be defined as converting primitive data type into it's equivalent wrapper type automatically. In Java,for every primitive type there is a corresponding class of reference...

Object Cloning

Object Cloning: Cloning means to create exact copy of an existing object. To clone a object we have to implement  java.lang.Cloneable interface by that class whose object will be cloned. clone() method is defined in Object class. Examp...

Difference between Import and Static Import in Java.

Import To access classes of one package in another package i.e use external classes without package qualification import feature is used. The classes and interfaces of one package are accessible in another package using impo...

Static Import in Java

Static Import Static import feature was introduced in Java 5. The functionality provided by static import is it allows a class to access static members of another external class directly without qualifying it with the class name as if it ...

Covariant Return Type in Java

Covariant Return Type in Java This feature of Java allows overridden methods to have different return types. Before Java 5.0, overriding a method a concept used in inheritance in which subclass can have same method as provided in sup...

Printing something without using main method

Printing hello without using main method: We can use static block to print something without using main method as static block executes as soon as the class is loaded. To ignore exception "System.exit(0);"  is used which termina...

How to to use Array object sorting method in java

 In the below example I have used ArraySorting method to sorting array object. Here I have initialized Object array and then I have used Array sorting method and java.util.Arrays.sort(Object[]) method to sort object ArrayList. You can see b...

Implementation of insertion sort in java

In java we have different sorting algorithm for insertion of element in an array. Let's talk about insertion sort today insertion sort is a uncomplicated algorithm, it raise the ultimate sorted array one item at a time. It is less coherent on...

Java Strictfp Keyword

Java Strictfp Keyword When operations on the floating-point variable are performed in Java, the precision may differ from one platform to another platform. To overcome this problem,Java programming language provide Strictfp Keyw...

Aggregation in Java

Aggregation in Java Aggregation in Java can be defined as relationship between two classes in which one class contain reference of another class therefore aggregation represent HAS-A relationship. An aggregate class containing reference of ano...

Error: Cannot change version of project facet Dynamic Web Module to 2.3

While working on maven project, encountered an error: Cannot change version of project facet Dynamic Web Module to 2.3. line 1 Maven Java EE Configuration Problem When I tried to run the project it was running fine but always giving t...

Scala

Scala is a programming language and full form is Scalable language. It first released in 2003. Scala is object-oriented and functional language. Many companies that depend on Java switching to Scala to enhance their development productivity, s...

How to create thread

Thread: A thread is a light-weight process which can run independently. A java program can contain multiple threads. Every  thread is created and controlled by the java.lang.Thread class. We can create threads in two ways: By extend...

Enum in java

Enum: It is a special data type used to define fixed set of constants . Enum can contain constants, methods etc. We can use enum with switch statement easily. Enum keyword is used to create enums. Example: class EnumDemo{ pu...

Different ways to create objects

Different ways to create object: We can create objects in java in four different ways.  Using new keyword Using Class.forName() Using clone() Using object deserialization Creating an object with the help of new keyword: ...

replaceAll() to replace square brackets in a String

To replace any character from a String, we generally use replaceAll() method of String. Below is the example String Str = new String("Hello + world +"); System.out.print("Output Value :" ); System.out.println(Str.replaceAl...

Marker interface in java - Serialization

Marker Interface in java: Marker Interface is an interface in which there are no members. i.e we don't define any methods or data members inside the marker interface. It is also called tag interface. A very obvious question comes in m...

java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.JavaType.isReferenceType()Z

I was integrating solr with java using maven dependencies  <dependency> <groupId>org.apache.solr</groupId> <artifactId>solr-solrj</artifactId> <version>5.5.0</version> ...

Command Line Arguments

Command Line Arguments: Command Line Arguments are those arguments which are passed during executing a program through console. Arguments passed from  console can be used in a java program and  can be taken as an input. Example...

Immutability in Java

An immutable object can be defined as an object that will not change state after it is instantiated. An immutable object can be made by defining a class which follows following rules: The class is to be marked as final. The memb...

Java heap size on Solr

I was working on a huge data, around 10gb, which I needed to import on solr. So I split the data in 1gb files, then I imported the data in solr using the post method. I ended up getting error: SEVERE: java.lang.OutOfMemoryError: Java heap s...

Error: No identifier specified for entity

I was working with spring 4 integration with hibernate 4 and encountered and error: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ...CustomConfiguration: Invocat...

Scanner Class in Java

Scanner Class in Java Scanner is a class contained in java.util package basically used for obtaining the input of the primitive types like int, double,and strings. To read input an object of Scanner class is created and various methods are use...

How to extend array after initialization by creating an new array

In the below example I have created extend array function. Here first I have define array length then extend new array value. You can see below program it will clearly describe to extend  array after initialization by creating an new array. ...
1 3 13
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: