Posts

Showing posts from June, 2015

What are the new features in java 7

Image
Still popular java interview question, yesterday I was appeared in one of the world's largest investment banking company's interview and interviewer asked me to list down the new features of java 7 I thought it was java 8 but when, I re-confirm then interviewer replied yes you have to list down the new features of java7. So, I decided to post a topic on new features of java 7, In this post I am going to list down all the new features of java7 with code example. The java 7 features are still on demand not only in real time use but in interview also like java program to balanced parentheses Below are the list of new features of java 7 String in switch Try-with-resources statement Underscores in numeric literals Binary literals Multiple exception catching Improved Type Inference for Generic Instance Creation SafeVarargs String in switch: Now you can use Strings in switch statements. public static void stringInSwitch(String months) { final String JAN = "...

How to convert List to Array in Java

Sometimes we required to convert Arrays to List or List to array in java while doing programming. In this post, I am going to show you how to convert List to Array in java. You can convert List to Array in three different ways and those are listed below in ListUtil.java . ListUtil.java package com.javamakeuse.poc; import java.util.ArrayList; import java.util.List; public class ListUtil { // For reference type or wrapper classes public static Integer[] getIntegerArray(List<Integer> numberList) { Integer[] numArray = new Integer[numberList.size()]; return numberList.toArray(numArray); } // or public static String[] getStringArray(List<String> strList) { return strList.toArray(new String[strList.size()]); } // for primitive types public static int[] getPrimitiveArray(List<Integer> numberLsit) { int[] priArray = new int[numberLsit.size()]; for (int i = 0; i < numberLsit.size(); i++) { priArray[i] = numberLsit.get(i); } return priArray;...

Java program to print repeated numbers in array

Image
While preparing for an interview, most of the candidates googled,the popular java interview question and start remembering those popular question's answer only. But nowadays only theory is not enough, if you are planing to change your job or looking for a better opportunity, than you must have to be not only technically but logically sound also. Nowadays, in any interview a programming question must asked, it doesn't matter if it's for Google,Amazon,Facebook JP Morgan or it's a mid level organization. Of course questions are not very tough. It's simple java program to solve any puzzle or finding the best way to achieve a solution based on time and space complexity, simple dead lock situation, implementing stack in java, java memory model etc. So I am planing to share with you simple java programing interview questions, like previously I already shared with you one of the very popular java programing interview question " Remove duplicate characters from a st...