Found 7442 Articles for Java

Any good resource for java interview questions

Jennifer Nicholas
Updated on 17-Jun-2020 13:50:04

223 Views

There are many sites which are good resource for java interview questions-answers. Following is the list of most popular websites.Tutorialspoint www.tutorialspoint.comStackOverflow www.stackoverflow.comDZone www.dzone.comWikipedia www.wikipedia.orgIBM Developer Works www.ibm.com/developerworks/java/TechGig www.techgig.comGitHub www.github.comJava documentation docs.oracle.com/javase/Coursera www.coursera.org/JavaWorld www.javaworld.com/

What are some good sites for Java interview questions

Rishi Rathor
Updated on 17-Jun-2020 13:23:21

173 Views

There are many sites which are a good resource for java interview questions-answers. Following is the list of most popular websites.Tutorialspoint  - www.tutorialspoint.comStackOverflow - www.stackoverflow.comDZone - www.dzone.comWikipedia - www.wikipedia.orgIBM Developer Works - www.ibm.com/developerworks/java/TechGig - www.techgig.comGitHub - www.github.comJava documentation - docs.oracle.com/javase/Coursera - www.coursera.org/JavaWorld - www.javaworld.com/

Top 10 websites for Advanced level Java developers

Nancy Den
Updated on 30-Jul-2019 22:30:21

729 Views

There are many sites which are a good resource for java interview questions-answers. Following is the list of most popular websites.Tutorialspoint - www.tutorialspoint.comStackOverflow - www.stackoverflow.comDZone - www.dzone.comWikipedia - www.wikipedia.orgIBM Developer Works - www.ibm.com/developerworks/java/TechGig - www.techgig.comGitHub - www.github.comJava documentation - docs.oracle.com/javase/Coursera - www.coursera.org/JavaWorld - www.javaworld.com/

Function pointers in Java

Akshaya Akki
Updated on 24-Feb-2020 12:48:19

2K+ Views

From Java 8 onwards, the lambda expression is introduced which acts as function pointers.Lambda expressions are introduced in Java 8 and are touted to be the biggest feature of Java 8. Lambda expression facilitates functional programming and simplifies the development a lot.SyntaxA lambda expression is characterized by the following syntax.parameter -> expression bodyFollowing are the important characteristics of a lambda expression.Optional type declaration − No need to declare the type of a parameter. The compiler can inference the same from the value of the parameter.Optional parenthesis around parameter − No need to declare a single parameter in parenthesis. For multiple ... Read More

How do I time a method execution in Java

Manikanth Mani
Updated on 25-Feb-2020 05:01:54

981 Views

You should get a start time before making a call and end time after method execution. The difference is the time taken. ExampleLive Demoimport java.util.Calendar; public class Tester {    public static void main(String[] args) {       long startTime = Calendar.getInstance().getTimeInMillis();       longRunningMethod();       long endTime = Calendar.getInstance().getTimeInMillis();       System.out.println("Time taken: " + (endTime - startTime) + " ms");    }    public static void longRunningMethod() {       try {          Thread.sleep(1000);       } catch (InterruptedException e) {          e.printStackTrace();       }    } }OutputTime taken: 1012 ms

Why is NullPointerException in Java?

Alankritha Ammu
Updated on 25-Feb-2020 05:02:26

291 Views

NullPointerException is a runtime exception and it is thrown when the application try to use an object reference which has a null value.For example, using a method on a null reference.Object ref = null; ref.toString(); // this will throw a NullPointerException

Why can't we define a static method in a Java interface?

Anjana
Updated on 17-Jun-2020 11:36:55

751 Views

From Java 8 onwards, static methods are allowed in Java interfaces.An interface can also have static helper methods from Java 8 onwards. public interface vehicle {    default void print() {       System.out.println("I am a vehicle!");    }    static void blowHorn() {       System.out.println("Blowing horn!!!");    } }Default Method ExampleCreate the following Java program using any editor of your choice in, say, C:\> JAVA.Java8Tester.javaLive Demopublic class Java8Tester {    public static void main(String args[]) {       Vehicle vehicle = new Car(); vehicle.print();    } } interface Vehicle {    default void print() { ... Read More

A closer look at Java "Hello World" program

Daniol Thomas
Updated on 24-Feb-2020 12:41:02

315 Views

Let us look at a simple code that will print the words Hello World.ExampleLive Demopublic class MyFirstJavaProgram {    /* This is my first java program. *    This will print 'Hello World' as the output */    public static void main(String []args) {       System.out.println("Hello World"); // prints Hello World    } }Let's look at how to save the file, compile, and run the program. Please follow the subsequent steps −Open notepad and add the code as above.Save the file as: MyFirstJavaProgram.java.Open a command prompt window and go to the directory where you saved the class. Assume ... Read More

How to get rows and columns of 2D array in Java?

varun
Updated on 24-Feb-2020 12:16:59

10K+ Views

Following example helps to determine the rows and columns of a two-dimensional array with the use of arrayname.length.ExampleFollowing example helps to determine the upper bound of a two dimensional array with the use of arrayname.length. public class Main {    public static void main(String args[]) {       String[][] data = new String[2][5];       System.out.println("Dimension 1: " + data.length);       System.out.println("Dimension 2: " + data[0].length);    } }OutputThe above code sample will produce the following result. Dimension 1: 2 Dimension 2: 5

How to convert comma seperated java string to an array.

Prabhas
Updated on 24-Feb-2020 12:15:58

6K+ Views

Yes, use String.split() method to do it. See the example below −Examplepublic class Tester {    public static void main(String[] args) {       String text = "This,is,a,comma,seperated,string.";       String[] array = text.split(",");       for(String value:array) {          System.out.print(value + " ");       }    } }OutputThis is a comma seperated string.

Advertisements