Various command line arguments in java when executing a program?

We can run a Java program with additional parameters. I’ll try to go over the most popular command line options that we can give to the java interpreter.

Getting help

Running `java -help` will print out a short help message explaining the usage.

Showing version

* `-version` – shows Java version and exists
* `-showversion` – shows Java version and […]

What are anonymous inner classes in Java?

Since the introduction of Lambda Expressions in Java 8 anonymous inner classes lost some relevancy. Nevertheless it is good to know where and how to use them especially if we must to work with legacy code bases. Anonymous inner classes allow to create an instance that implements some interface without giving it an explicit name.

When […]

What are read only collections in Java? Do they improve concurrency issues?

What are read only collections?

In Java read only collections provide a standard way to create a unmodifiable copy of any collection. Read only collections are useful as a way to provide an immutable view of a `List`, `Set` or `Map`.

To create a read only collection we use the methods provided in the `java.utils.Collections` class. See […]

How to write/use equalsIgnoreCase method of String class in Java

Writing our own equalsIgnoreCaseMethod

How could one go about writing a `equalsIgnoreCase` method that compares two `Strings` ignoring case? We will only consider simple cases in which either comparing to the upper case or lower case is sufficient (there are some alphabets in which this is not true).

Use equals method
First of all I must say there […]

Write a program to delete an item from array and then reorder them

In this lesson we will write a program that deletes an item from an array and then reorders the elements to fill the empty space.

In Java we don’t have to manually delete elements – if we remove all references to a variables from the memory the garbage collector will remove it upon earliest convenience.

Approach Number […]

Use of having packages and package statements in java

Packages are very useful in large scale application. To understand the concept of package, developers must have basic knowledge of java programming. Java provides a facility to reuse the functionality of same code in different file. Reusability of code is one of the most important requirements as it saves time, effort and also ensures consistency. […]

How to compile and run a Java application

Java is the one of world’s most powerful and popular programming language nowadays. Basically Java is used to develop software, computer games, robotics and in large scale applications. Also android app development is based on Java. So due to all this reasons, developers are very much eager to learn and write code in Java.

This tutorial […]

How does invoking yield method on Thread differ from sleep method?

Introduction to scheduling threads
To say how `Thread.sleep(long)` differs from `Thread.yield()` we first must understand how they are same. Both methods deal with how the processor schedules the given Java thread.

Scheduling in computer science is a method of dividing a finite resource – but for the time being we’ll only consider CPU time. The exact […]

Difference between Java `import` and c++ `#include` statements

The Differences

The biggest difference between `#include` and Java’s import statement is that `#include` is a preprocessor directive and `import` is a Java language construct.

`#include` doesn’t know the concept of compilation units, classes etc it only “knows” the concept of files and text insertion. A result of `#include “foo.h”` is that the contents of the […]

How to reverses a string without using reverse method from JDK

Suppose we wanted to write our own version of String.reverse(). How could one go about such a thing? We will consider simple string reversal ignoring two character code sequences such as:

Reference link to wikipedia: surrogate pairs

Recursive approach

Let’s start with a very naive recursive approach:

In the example above we subdivide the string recursively and concatenate the […]


Enter your email address:

Delivered by FeedBurner

Java ExperienceA place for all type of Java web tutorials2014