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

How hashMap internally works in java ?

It’s not wrong to say that HashMap is an implementation of Map interface as it allows value storing in key value pairs. Although unique elements are present in Hashmap, null values and only one null key are allowed. Hashmap basically wor...

What is Factory Pattern?

Factory pattern is one of the most used design patterns in java with the help of this pattern you can create object easily by using this concept of oops. Example of Factory pattern : 1. Create an interface 2. Create class that 'll ov...

Data structure when to use what ?

We have different types of data structures like array, linked list, tree etc but which one is better so this is basic question that comes in mind every time when we have large data set. In this post we can find out the best data structure type...

Jcrop image croping

1- Place JS and CSS files under head tag. jquery.min.js jquery.Jcrop.js main.css demos.css jquery.Jcrop.css   2- Also copy and paste bellow piece of javascript code under head tag. <script type="text/javascript"...

Travelling Salesman Problem

Hello!!! Travelling Salesman Problem is for finding the shortest possible root that visit every node in the graph and return to the origin point. It is used to find the shortest path. For example:- In this graph, Their is many way to rea...

How to Print All Leaf Node of Binary Tree

Hello Everyone!!!   In order to solve binary tree problem of leaf node, we should know that what is leaf node? Leaf node is node of the binary tree whose have no left and right child means whose left and right child is null. It...

Most Popular Application Development Frameworks 2016

      "Developing mobile applications used to mean that you had to write native code, for each individual device or operating system that your client required. However, these past few years the term Hybrid App Deve...

Convert bytes to human readable form Android Java

Convert bytes data to human readable form. 1.  I initialized the byte with random number; long bytes = 123456; 2.  Initialize String[] of data types. String[] types = {"kb", "Mb", "GB", "TB", "PB", "EB"}; 3. initial...

Default methods and static methods uses in Interface.

We know that interface provide methods without body or functionality but in abstract class we can provide default functionality of methods. So in interface we can't give method body and can't declare ant static method. But in Java 8 no...

Comparator Interface in Java

Comparator:- Comparator interface  found in java.util package and it contains equals() and compare() method. It use the multiple sorting technique to write our own comparison logic and is used to sort the e...

Comparable Interface in Java

Comparable:- Comparable interface  found in java.lang package and it contains only compareTo() method. It use the single sorting technique to write our own comparison logic and is used to sort the elements on the basis of...

Facebook OAuth Authentication using Java

Hi, This blog is to help you to get Facebook Authentication through OAuth using Java. As Facebook is not offering any SDK for Java clients so with the use of a Json parser we are going to develop a small web application in order to u...

ThreadGroup Class

ThreadGroup in Java: It represents combination of threads within a group. A thread group can also include other thread groups .With the help of thread group we can easily suspend, resume or interrupt group of threads by a single method call. ...

Synchronized block

Synchronized block: Synchronized block is mainly used when there is a sharing of resources and it is used to lock an object for any shared resource so that at a particular time only one object can use that resource. By using synchronized block...

Main Thread in java

Main Thread: When we run a Java program  then main thread begins running immediately. It is created automatically. The main thread is the first as well as last thread in a java program to end. It is the main thread from which other chi...

HashSet Class

HashSet Class: It extends AbstractList class and implements List interface. It uses hashing technique to store data. It contains only unique elements. We can use HashSet class by importing java.util package. Example: import java.util.*...

LinkedList class

LinkedList class: It provides a linked-list data structure. It uses doubly linked-list to store elements. It extends the AbstractList class and implements List  interface. We can use LinkedList class by importing java.util package. Exa...

NOT LIKE in Hibernate Criteria

The Hibernate Criteria Not like, selects the records that don't match to the matching string given in like parameter. Example: Criteria criteria=session.createCriteria(Tickit.class); //Here you can pass class on which you want to perf...

Formatting date in different format in java

Formatting Date in java: There is a predefined format for dealing with dates in java , but suppose if you want the date in some other format other than the default one then you can use the SimpleDateFormat class of the java.text ...

Getting object values from json data

Getting object values from Json: If you have a data in Json format and you need to retrieve the object values from that day, it can be easily done using Java.   Lets see an example,  If you are using maven add the following ...

Pass element id that triggers `onclick` event to the event handling function

When we apply onclick event to an element, sometimes we need to pass ID of that element to the event handling function. We can do this by passing id to function as this.id or we can pass the element itself. Example: In the below example I'...

Getting current url in jQuery

Sometimes we need to identify which is the current URL of JSP page to perform some functionality. We can do this very easily by adding the below line in you on load function:   $(function(){ var url = window.location.href; ...

Creating object in Json format using java

Json object: You easily write your object in json format with java . Json format is used because it becomes easy to exchange information in this form. It is easy to understand and easy to write. Lets see an example,  If yo...

Static and Dynamic binding in java

Static Binding: It determines the the type of object at early stage during the compilation itself, i.e. it tells that the object belongs to which class during the compile time of the program.  There is no ambiguity in deciding the type...

Printing current Date in Java

Date Class in java: There is a Date class in java under java.util package which can be used to print the current dates. There can be various ways to print the current date. Lets see with the help of example: import java.util.Date; ...

Convert Xml to Json format using java

Xml to Json conversion: Lets see with the help of example. Following jars are required for conversion: apache-commmons json-lib ezmorph Suppose we have the xml file with name demo.xml with the following data: ...

Setting limit for the no. of words per record in solr while fetching

Fetching records in solr: Once you have finished with indexing in solr, now you can perform search on your records with the help of queries. Go to the url: http://localhost:8983/solr/#/collection/query  There is box with q,&...

Instance Initializer block in java

Instance Initializer Block: There are two types of data members: static and instance data members.  Instance data members are those that belongs to instance of a class. i.e objects. Here comes the role of instance initializer block. It...

How to use Custom Exception in android

Custom Exception is user-defined exception. It is used to customize the exception according to the user requirement. Here In step one we have defined own exception . In step second Using the custome defined exception extends "Exception"...

How to Overload main() method ?

Overloading Method: Overloading Method can be easily defined by having multiple methods with same name but with different parameter, in a Class. Difference in Parameter can be in number of parameters used in method or change in type of paramet...

Is it possible to run program without main method?

Can we execute a program without using main? Answer is yes, we can run a program without using main with the help of static block. Lets see about static block first. Static Block: It is block which can be used to give initial values to t...

Export from a list containing objects to excel file in java

Suppose you have a list containing objects. You can export it to the excel file.  You will require the following jars for this: xmlbeans-2.3.0.jar poi-3.9-20121203.jar poi-ooxml-3.9-20121203.jar poi-ooxml-schemas-3.9-20121203....

How to use 'toString' method ?

toString(); This method is used to convert any object in Java to String format. If we want to get object, Java Compiler automatically invokes 'toSting()' . Although we can override this method if required. Lets Consider following examp...

Deleting documents in solr collection

Deleting documents: Suppose, you have collection with the name of demo and you have indexed your file in the server in this collection but you want to delete all the documents or some of them, then it is possible by two ways: Deletion by So...

How to Use 'strictfp' in Java.

In Java Programming, we all are aware that precision in result specially in floating-point numbers vary from platform to platform. In order to avoid such consistency in result over different platform, Java language provides the keword named '...

Indexing in Solr Server

Indexing: Solr gives you a quick response and results because of indexing. What does this mean? It means that it searches index instead of the text to retrieve the results for you. In book , you search for the index in the index page of the...

Program to print pascal's triangle using a 2D array in java

Pascal's Triangle:   Program to print Pascal's triangle: import java.io.*; public class Pascal{ public static void main(String []args)throws IOException{ InputStreamReader isr=new InputStreamReader(S...

Solr update using solrTemplate for incremental value

In previous blog Solr Atomic update with incremental popularity, we have updated the solr incremental field using SolrDocument.    Now we will update it through solrTemplate. Here is the sample code: PartialUpdate update =...

How to disable mongoDB java driver logging

Go to mongodb configuration file and add following lines of code. @Configuration public class SpringMongoConfig extends AbstractMongoConfiguration{ static Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); sta...

How to Validate ISBN ?

ISBN Number ISBN is an acronym for "INTERNATIONAL STANDARD BOOK NUMBER". It is a 10 digit Unique Number for Book Identifier.This number used for each new edition except Reprinting Books. Now the Question is How to verify this number ...

How to make PIGLATIN Word ?

Piglatin : Piglatin is a way of forming a word by  finding the vowel and trace the alphabhet to the end and adding the "ay" at the End. For example: if the input word is "DEMO" then piglatin word will be "EMODAY"...

Fetching String of specified length in solr

For fetching a string for a specific value and length, here are 2 ways to do that. First using @Query and another using solr Criteria. In the below code it first searches for the string match and then suing filters we have defined the length o...

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

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 *...
prev 1 3 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: