Posts

Showing posts from June, 2018

Automatic Switch Between LAN & Wifi in Windows 10

Image
Steps to switch between LAN and Wifi Automatically. 1.        Go to Control Panel -> Network & Sharing Centre   -> Change Adapter Settings 2.        Git ‘Alt’ button to get Menu items 3.        Click Advanced -> Advanced Settings 4.        Change the order like below. 5.        Click Ok. Note : First preference will be LAN if connected.

First Non Repeating Character Using Java 8

Hi Friends, In this post, we will see the program for FirstNonRepeatingCharacter in java. package com.raj.programs; import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; public class FirstNonRepeatingCharacter { static Character getFirstNonRepeatingCharacter(String input) { Map<Character, Integer> table = new LinkedHashMap<>(input.length()); input.chars() // IntStream .mapToObj(c -> (char) c) // converting into char .forEach(ch -> table.put(ch, table.containsKey(ch) ? table.get(ch) + 1 : 1)); // putting in map return table.entrySet().stream() // getting stream from map entries .filter(entry -> entry.getValue() == 1) // getting only the entries which presented only one time .map(Entry::getKey) // getting the entry keys alone .findFirst() // getting first element in the key list .orElse(null); // If none found, null will be returned } public static void main(String[] args) { ...

First Recurring Character Java Program

Hi Folks, Below the source code for FirstRecurringCharacter in java. package com.raj.programs; import java.util.Hashtable; public class FirstRecurringCharacter { public static String firstRecurring(String inputString) { Hashtable<String, String> table =  new Hashtable<>(inputString.length()); for(char c : inputString.toCharArray()) { if(table.containsKey(String.valueOf(c))){ System.out.println("First Recurring character is : "+c); return String.valueOf(c); }else { table.put(String.valueOf(c), String.valueOf(c)); } } System.out.println("Not found"); return null; } public static void main(String[] args) { FirstRecurringCharacter.firstRecurring("ABCDEFA"); FirstRecurringCharacter.firstRecurring("ABCDEF"); } }