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

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-...

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 ...

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...

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...

What is Daemon thread in java ?

In java any thread can be a Daemon thread. Basically daemon thread are those that works in background to support or to provide services for users threads running in same process. If there are no any user threads available while daemon threads ...

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...

Sting Builder vs String Buffer in java

We know that Strings are immutable or constants but String builder and String buffer are basically used to provide dynamic implementation of Strings. But String Builder is not thread safe that means more than one process can access or modify t...

What is anonymous inner class in java and how to implement interface in annonymous class ?

Anonymous means no name, a class with no name called as Anonymous class. But is has advantage like to create an instance of class in one step. We can'e create an object of this class since it has no name. An anonymous class can implemen...

Transient varialbe in java

We know that serialization is the process that converts java objects or data into bytes stream on one end and on other end we deserialize it that means convert bytes into orignal data.   Serialization means to save data after serializa...

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...

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...

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...

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. ...

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...

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 ...

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...

Deletion of node from binary search tree in java

Like a linked list we can also delete a node from binary search tree. This operation perform O(log(n)) time complexity. Here is an example of deletion : private TreeNode delete(TreeNode rootNode, int k) { // create a node to store tem...

gherkin.parser.ParseError in cucumber feature file.

 I created the below scenario in a cucumber feature file and when I executed the scenario then I got gherkin.parser.ParseError Scenario : The user should be able to login for correct credentials Given I am at the Home page ...

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> <...

Binary search tree insert item implementation in java

Binary search tree is an extension of linked list data structure that contains node. Insertion in tree is easy. This tree contains a root and child node where left hand sided node always lesser than parent node and right hand sided node always ha...

Queue implementation using linkedlist in java

We know that linkedlist is type of Data structure using linked list we can store item of same type. Queue can be also be implemented using linkedlist. In this example we have two node that are head(Front) and trail(rear) where we can insert...

Queue implementation using Array in java

Queue is a kind of Abstract data structure that holds items in same order. Queue follow FIFO mechanism for operations like insertion and deletion of items. Note : - One end is always used to insert data called enqueue. - Other end is alw...

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...

traverse and reverse double linked list in java

Traverse and reverse a linked list takes time complexity of O(n). Traverse a double linked list requires only node next reference until it reach to trail or null value : public void traverseLinkedList(){ Node<T> tempNode = st...

Deletion in double linkedlist in java

Deletion of item from double linked list st known position takes O(1) complexity while deletion at some specified position takes O(n) time complexity. In deletion we basically removes the pointer of that item. First of all check the reference ...

Insertion in double linked list in java

Double linked list is a type of data structure that contains data in linear way but its different from single linked list because we can traverse in both direction in list. This provides previous and next pointer and node value. Insertion in d...

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...

How to reverse linkedlist in java ?

There are two way to reverse a linked list that are using recursion or using iteration. This operation takes O(n) time complexity during iteration method. Here is the code to reverse linked list using iterator : public void reverseLinked...
prev 1 2 6
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: