Blog Archives

String StartsWith and EndsWith in JavaScript

The following are a simple implementation checking whether a string starts with a prefix or ends with a suffix in JavaScript. Here we use indexOf() method of JavaScript String object. Syntax: string.indexOf(search, start) Parameters: search is the string to search

Tagged with: , ,
Posted in JavaScript

Compare Strings in Java

The String class provides a method equals() to compare string values. The double equal sign == only compares the references, not the values. Here “a” and “b” are pointing to two different String objects. The equals() method will check the

Tagged with: , , ,
Posted in Java

Convert between String and Char Array in Java

Convert a String to an Array of Characters The String.toCharArray() method converts a string to a new character array. The following code gets an array of Character objects, instead of a character array. Convert an Array of Characters to a

Tagged with: , ,
Posted in Java

Store Locator using Java

We would like to write a program to find the closest store to an input address. The program is provided with a list of locations; it asks for an input address, and then outputs the closet store location. The dataset

Tagged with: , , , , ,
Posted in Java