This example demonstrates how to get the classpath string using the Java program. It is simple that you just need to use the System.getProperty() method with the classpath variable name which will return the classpath string. Lets look at the example. Output This is the simple example to get the classpath configuration in your system …
Java Basics
Array Vs ArrayList in Java
What is the difference between Array and ArrayList is the quite common question for the Java interview and for the beginners who are learning Java programming. I have started writing the Java best practices series, this is one of the post for clearing the air on misconception about popular Java classes Array and ArrayList. 1. Flexible …
How To Use Source and Target Parameter in Java Compiler
If you are a Java programmer, then one of the common question comes into mind is How do I compile for compatibility with older versions of Java?. When you run your Java program with an older version of the Java runtime environment, you may get the following Java exception if you have not compiled with the right version of …
Difference Between Abstract Class and Interface in Java
One of the basic Java interview question is what is the difference between abstract class and interface. If you are a beginner in Java, you can not avoid this question in any Java interview to test your knowledge on Java OOPs concepts. In this short tutorial I will write down the difference between abstract class …
Suppressed Exceptions in Java 7
At any point of time only one exception can be thrown by a method per execution. In cases when more than one exception would be thrown from the method, one of them will be suppressed and not thrown by the compiler. This exception is known as the suppressed exceptions in Java. Additional Reading : Java …
Java Exceptions Tutorial
In this tutorial I am going to explain Java exceptions in details and how to use them in the real applications. One of the important measure to assess the quality of your Java code is to review the exception handling and how exceptions scenarios are handled. If you have to write an efficient exception handling, …
Downcasting In Java
Upcasting is assigning the sub class reference object to the parent class which is allowed in Java. Downcasting is assigning parent class reference object to the sub class which is not allowed in Java. However, if you do downcasting, there will not be any compiler error. But, there will be runtime exception java.lang.ClassCastException. Then why …
Static Nested Class In Java
Static Nested classes are inner classes which are declared inside another class and also declared with static keyword. The main difference between inner class and static nested classes is that inner classes are non-static and static nested classes are static. Also known as static classes. Static nested classes can be accessed using the enclosing class …