Q1) // Write a Java Program To Find Out the Character Occurnaces In A String. import java . util . HashMap ; import java . util . Map ; public class CharOccurnacesInString { // Write a Java Program To Find Out the Character Occurnaces In A String. public static void main ( String [] args ) { String str = "I am Sandeep Aswar" ; str = str . replaceAll ( " " , "" ). toLowerCase (); char [] ch = str . toCharArray (); Map < Character , Integer > charMap = new HashMap <>(); for ( char c : ch ) { if ( charMap . containsKey ( c )) { charMap . put ( c , charMap . get ( c ) + 1 ); } else { charMap . pu...
Java 8 Programs Asked In Interview For Experienced Professionals | Java 8 Coding Interview Questions Asked In The Interview.
Q1) // Given Two Strings. Find Out the Two Strings are Anagrams or not. // Anagram means a String which has same characters present with the another // String, // Only the sequence of the Characters are different. package J ava C oncept O f D ay ; import java . util . stream . Collectors ; import java . util . stream . Stream ; public class AnagramStrings { // Given Two Strings. Find Out the Two Strings are Anagrams or not. // Anagram means a String which has same characters present with the another // String, // Only the sequence of the Characters are different. public static void main ( String [] args ) { String str1 = "Listen" ; String str2 = "Silent" ; str1 = Stream . of ( str1 . split ( "" )). map ( String :: toLowerCase ). sorted (). collect ( Collectors . joining ());...