Java Scanner Class With Examples

java

In this article I shall discuss about the Java Scanner Class. I shall discuss about the concept with some examples. When you get to know the basics of programming, with time comes the desire that a developer has to work with novice programs in text mode (console). With this principle, many begin to use the […]

Working with java.util.zip compression API

In this article I shall discuss about how to compress files using Java. Java has a package of classes that allow data compression.Let’s see how easy it is to compress all files in a folder.The first step is to import the classes that we will use: Working with java.util.zip files Package java.io classes will be […]

Example for a class implementing comparable interface in Java

When you need some sort of ordering for the classes which you define, you will be going either for a comparable or comparator interface. Consider this example package test; import java.util.*; public class TreeSetTest { private static Set<Person> s = new TreeSet<Person>(); public static void main(String a[]){ s.add(new Person(20)); s.add(new Person(30)); s.add(new Person(10)); s.add(new Person(50)); […]

What is super and this keyword in java?

keyword : this ‘this’ is used for pointing the current class instance. It can be used with variables or methods. Look into the following example: class Test{ private int i=10; public void m(){ System.out.println(this.i); } } In the above code this is used for the current instance. Since this is instance of a class it […]

How to use BitWise shift operator in Java?

They are called shift operators and they operate by shifting the number of bits being specified as an operand in the operation. >> —> Right shift Operator << —> Left Shift Operator >>> —-> Right bit with zero fill operator. The first two maintain the MSB when shifting thereby they maintain the sign of the […]

What is difference between equals() and == ?

Explanation : 1 They both differ very much in their significance. equals() method is present in the java.lang.Object class and it is expected to check for the equivalence of the state of objects! That means, the contents of the objects. Whereas the ‘==’ operator is expected to check the actual object instances are same or […]

Difference Between List and ArrayList ?

List is an interface and ArrayList is an implementation of the List interface. The arraylist class has only a few methods in addition to the methods available in the List interface. There is not much difference in this. The only difference is, you are creating a reference of the parent interface in the first one […]

What is the difference between JRE,JVM and JDK?

java

If you are a Java developer, it is very often that you think about understanding the JRE,JVM and JDK. Once if you understand these things, it would be quite easy for you to visualize things in logical manner. Also look at the picture below, that will clear all your questions about the JRE,JVM and JDK. […]

Java HelloWorld vs Scala HelloWorld

scala-thumbnail

As a first step into learning Scala and as one who is familiar with Java, let us compare the customary Helloworld programs in Java and Scala. You might already know that to run a Java program, there must be a public class with a┬ámain┬ámethod that takes one parameter, a String[ ], and has a void […]

Handling/Avoiding Null’s in Java using Guava versus Scala

java-thumbnail

There was a discussion about nulls in the latest episode of JavaPosse. Having been inspired from that discussion and with an urge to check out Google Guava library, I came across a way to handle Null’s in Guava which is very similar to the way Scala handles. also read: Java Tutorials Java EE Tutorials Design […]