java

java

Java Program to get the last modified date and time of a file

In this tutorial, we will learn how to print the last modified date and time of a file in Java. For this, we will first create one 'File' object. To create one 'File' object, pass the file's location to the constructor. If you want to get the full path of a file, open one terminal and drag-drop one file on the terminal. It will print its full path.

Read
java

Java program to print the ASCII value of an integer

American Standard Code for Information Interchange or ASCII code links an integer value to a symbol like letter, digit , special character etc. In ASCII 7 bits are used to represent a character. From 0 to 127, each number can be represent by a character. In this tutorial, we will learn how to print ASCII value of an integer.

Read
java

Java program to find out the top 3 numbers in an array

In this tutorial, we will learn how to find out the top 3 numbers in an array. Algorithm used in this program is as below :.

Read
java

Java Program to Delete a file using 'File' class

In this example, we will learn how to delete a file in Java. In the below program, the full path of the file is stored in 'fileName' variable. First we create one 'File' object using 'File(fileName)' constructor. Then we will delete that file using 'delete()' function. It will return 'true' if the file is deleted successfully. 'false' otherwise.

Read
java

Java Program to print the sum of square series 1^2 +2^2 + ..... +n^2

In this tutorial, we will learn how to calculate the sum of the series 1^2 +2^2 +3^2 +4^2 + ..... +n^2 ( where n can be any number ) and print out the series with the sum as well.

Read
java

Java program to find the area and perimeter of an equilateral triangle

In this tutorial, we will learn how to find the area and also perimeter of an equilateral triangle in Java.

Read
java

Java BufferedReader and FileReader example read text file

In this example, I will show you one basic Java File I/O operation - "Reading the contents" of a text file. We will use 'BufferedReader' and 'FileReader' class in this example. What these classes are used to do mainly ?

Read
java

Bubble sort in Java with Examples

Bubble sort repeatedly compares each elements in an array. We will traverse the array from the first element and check if it is greater than the second. If it is greater than the first, we will swap the first element with second. Then we will check the second element with third etc. This swapping will continue until no swap is needed.

Read
java

Java Program to calculate BMI or Body Mass Index

BMI or body mass index can be calculated by taking the weight in pounds and height in inches or by taking the weight in kilograms and height in meters. We have to use a different formula for both cases. In this example, we will learn how to do the calculation by using any of these two different approaches.

Read
java

Java program to convert a string to lowercase and uppercase

In this example, I will show you how to convert all characters of a string to uppercase or lowercase. First we will take the input string from the user using 'Scanner' class and then convert it to upper and lower case using following two methods :.

Read