Category Archives: Java Tutorial

2 examples for formatting dates by Java SimpleDateFormat class

The simple Date class of java.util package does not provide enough methods to work with the date formatting in Java applications. The Date() class is good to use if you intend to work with the current date.

Java equals method to compare strings

The equals method of the String class is used to compare two strings whether two are the same or not.

Java Hello world: Your first program

Until now, we learned what is the Java programming. After setting up the environment (JDK) to execute the Java code, it is time to write our first program of Java i.e. the “hello world” program.

How to declare and use the Java Boolean data type

Java has eight primitive data types to store data in its programs. The boolean Java is one of the primitive data types.

2 demos of converting Java int to double and double to int

You may convert the variable of data type double to int and int to double quite easily in Java programming. The example below shows how to convert that.

Java toString method

The Java toString is a String class method. This method returns an object’s string representation.

2 examples to understand Java string split

The Java split method of the String class is used to split the given string. The whole string will be broken by the given regular expression (regex).

How to use Java string replace method?

The replace method of the String class is used to replace existing characters in a given string to the new given characters.

3 examples of Java int to string conversion by valueOf and toString methods

In the previous chapter, we learned how to convert strings to int data type in Java. You can also convert an int to a string by using the built-in methods provided by Java. These methods are explained below with examples.

Java date (java.util.date) with 4 examples

Java comes up with a few date related classes to work with date and time in the Java projects. The Date class is one of those. The Date class is the part of java.util package.