Added By: Feedage Forager Feedage Grade B rated
Language: English
binary tree  java regular  java  method  number  random  regular expression  scanner  security number  social security  sort  string  tree 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics

Effective Programming Tips

Last Build Date: Thu, 22 Feb 2018 06:06:04 +0000


Insertion Sort Implementation in Java

Mon, 22 Jan 2018 03:16:32 +0000

Insertion sort is a simple algorithm. Insertion sort logic works as follows: To insert an element in an already existing set, we make room for the new item by moving larger items one position to the right. Then insert the new item at the newly available position. The algorithm most often used to sort cards in ...

Selection Sort Implementation in Java

Sun, 21 Jan 2018 01:27:53 +0000

Selection sort is one of the simplest sorting algorithms. It is easy to implement but it is not very efficient. The algorithm divides the input list into two parts: the sublist of items already sorted, which is built up from left to right at the front (left) of the list, and the sublist of items ...

Calculate Height of any Tree in Java (Non-Binary Tree)

Mon, 01 Jan 2018 22:10:52 +0000

Computing height of a tree in Computer Science is very common. Most of the examples and online discussions talk about computing the height of a Binary Tree. The example method I am sharing can be used to compute the height of any tree. So even if you have a non-Binary tree, you can use this method ...

Easiest Way to calculate elapsed time in Java

Sat, 23 Dec 2017 16:53:56 +0000

Quite often in our day to day programming, we need to compute how long does a specific portion of the code takes to complete. For e.g; you might want to check how long does a method take to complete.  In Java, the simplest way to accomplish this is to use System.nanoTime() method. Following example shows ...

Java Regular Expression to Validate Social Security Number (SSN)

Fri, 08 Dec 2017 03:17:31 +0000

Here is a utility method to check if a given String is a valid Social Security number using Java Regular Expression.  /** isSSNValid: Validate Social Security number (SSN) using Java regex. * This method checks if the input string is a valid SSN. * @param email String. Social Security number to validate * @return boolean: ...

Java Regular Expression to check if a String is a number

Mon, 04 Dec 2017 20:40:45 +0000

Here is another method from my String utility class. This method uses a regular expression to check if a String is a numeric value. Look at the code, then read through the explanation that follows public static boolean isStringANumber(String str) { String regularExpression = "[-+]?[0-9]*\\.?[0-9]+$"; Pattern pattern = Pattern.compile(regularExpression); Matcher matcher = pattern.matcher(str); return matcher.matches(); } ...

How to delete Workspace from Eclipse Launcher Selection

Sun, 03 Dec 2017 23:05:15 +0000

Launch Eclipse Click on Recent Workspaces Eclipse will list all previously used workspaces Right click on the workspace name that you want to remove Click on Remove from Launcher Selection text. This will remove the workspace from the drop-down list

How to generate random alpha numeric String in Java

Fri, 01 Dec 2017 22:20:01 +0000

Following code is an example of generating a random alpha-numeric string using Java Random class. It is designed to generate random String of varying length based on the input parameter. Here is the code package com.zparacha.utils; import java.util.Random; import java.util.Scanner; public class StringUtilities { /** * * @param n * Desired Length of random string ...

Java Scanner class not reading correctly after nextInt() or nextDouble method call

Tue, 28 Nov 2017 03:45:57 +0000

Scanner is a utility class that provides methods to read command-line input. It is a very useful class, but you need to be aware of its unexpected behavior while reading numeric inputs. Consider following example. try (Scanner in = new Scanner( { System.out.print("Enter Item ID: "); String itemID = in.nextLine(); System.out.print("Enter item price: "); double ...

How to compare Strings in Java

Sat, 25 Nov 2017 20:07:31 +0000

One of the most common bugs I’ve seen in Java programs in the use of == operator to compare two String objects. Most of the times the result may be accurate but it is not always guaranteed. We need to understand the difference between == and the Object.equals method. The == operator checks the reference ...