Tag: Java

Java String Array of Iterators

Problem Given the Java method signature below. It receives an array of string iterators. The method should return a single string iterator that chains all iterators in order skipping null values public static Iterator iterateStrings(List<Iterator> stringIterators) Solution We wrap the array of iterators in a list that implements the iterable interface and override the hasNext,

Java Singleton Cache Example

Problem Given the Java cache interface below, write a singleton class that implements the interface so that no warnings are generated without using @SuppressWarnings annotations //Generic Cache Interface public interface Cache<K, V> { public void put(K key, V value); public V get(K key); } Solution The question is mainly about two points: Type checking warning must be

Sikuli Selenium Robot Framework Tutorial

Introduction In this tutorial I will demonstrate how to integrate Sikuli (open source image based test automation tool) and Selenium (object based web automation framework) into Robot Framework (keyword and data driven test automation framework). This is not a Robot Framework Tutorial nor a Sikuli Tutorial. For more information about these technologies please visit their

Lexicographic Order in Java

Lexicographic Order Problem Write java method to compare two strings lexicographically. The method should return 0 if the two strings are Lexicographically equal. It should return 1 if the first string comes before the second string in the dictionary. It should return -1 if the first string comes after the second string in the dictionary.

Java Replace String Function

Problem Write a Java method to replace a sub string in a given text with another string of the same size Solution Loop through the text character by character. Starting at the current character loop a number of times equal to the size of the sub string while comparing characters in the original text and the sub