Found 2616 Articles for Java

Java Program to Print the Elements of an Array

Saba Hilal
Updated on 23-Mar-2023 12:04:33

694 Views

In this article, Array elements are selected for printing the elements by using their index value. The array is the common way to store similar types of items together in java. The individual values as well as all elements of the array can be printed easily. For printing, for all elements of an array a "for loop" is commonly used which selects the index from 0 up to the length of the array. Following are the few examples of integer and string type array Int type array example int [] array1 = {11, 22, 32, 42, -52, 62, -72, 82, ... Read More

Java Program to Print the Months in Different Formats

Saba Hilal
Updated on 23-Mar-2023 11:58:42

510 Views

This article uses various approaches for formatting the months using different libraries and using corresponding import statements in Java language. There are lots of ways to display months in the Java program outputs. Sometimes the months are written as numbers, sometimes the months are written in long form or they are written in short forms. The Month names are also written in other Languages such as Spanish, French, etc. Algorithm Step 1 − Ask the user to enter the date. Step 2 − Identify the month part of the date. Step 3 − Specify the format for the month. ... Read More

Eclipse fails to start via an Application Launcher

Satish Kumar
Updated on 14-Mar-2023 16:09:40

4K+ Views

Eclipse is one of most popular Integrated Development Environment (IDE) used by millions of developers around world. It provides a comprehensive set of tools and features for developing Java applications, web applications, and other software projects. However, like any software, Eclipse may encounter issues and errors that can prevent it from starting up via an application launcher. In this article, we will discuss some common causes of Eclipse startup failure and how to troubleshoot them. Possible Causes of Eclipse Startup Failure Corrupted Installation One of most common reasons why Eclipse fails to start is a corrupted installation. This could be ... Read More

Installing Java on Linux using SSH

Satish Kumar
Updated on 14-Mar-2023 17:07:27

1K+ Views

Java is a popular programming language that is widely used for developing various types of software applications. Linux is one of most popular operating systems used for software development due to its stability, security, and open-source nature. In this article, we will discuss how to install Java on Linux using SSH. SSH (Secure Shell) is a secure network protocol used for remote login to a server. It allows users to log in to a remote server and perform various operations using command-line tools. This makes it an excellent choice for installing Java on a Linux machine. We will be using ... Read More

Java Program to Encode a Message Using Playfair Cipher

Pranay Arora
Updated on 10-Mar-2023 11:31:25

2K+ Views

Encrypting is the task of transforming information into an unreadable format or cipher text. It is usually done to protect the confidentiality of information. There are many ways and algorithms to encrypt data. One such example is the Playfair cipher algorithm. In this article, we are going to see how to write a Java program to encode a message using Playfair cipher. Playfair cipher makes use of a 5X5 grid or matrix and a set of pre-defined rules. To encrypt, we require a key and the plain text to be encrypted. Steps Now let us see the steps to encrypt ... Read More

Java Program to Empty an ArrayList in Java

Pranay Arora
Updated on 10-Mar-2023 11:25:18

344 Views

ArrayLists in Java are a dynamic array who’s size can grow or shrink as elements are added or deleted from it. It is a part of the “java.util” package and is a very commonly used collection. An ArrayList is pretty much like an array as it stores elements of the same or homogeneous type in a contiguous block of memory. In this article, we are going to se the different ways to empty an ArrayList in Java. There are mainly 4 approaches to empty an ArrayList in Java and are as follows − Using the Naïve method Using the ... Read More

Java Program to Display Numbers and Sum of First N Natural Numbers

Pranay Arora
Updated on 10-Mar-2023 11:22:28

937 Views

Natural numbers are all positive integers or whole numbers that range between 1 to infinity. In this article, we are going to see how to display numbers as well as the sum of the first N natural numbers in java where n is defined by the user. Mathematically speaking, the sum of 1st N natural numbers is given by the formula − Sum = n * (n+1) / 2 In order to implement this in java, there are mainly 3 methods with a slight difference. 1. Using a for loop or do while loop or while loop The approach here ... Read More

Java Program to Display Floyd's Triangle

Pranay Arora
Updated on 10-Mar-2023 11:20:42

477 Views

Floyd's triangle is a popular right-angled triangular array consisting of natural numbers. The name comes from its founder Robert W. Floyd who was a prominent computer scientist. It is formed by starting with the number 1 at the top of the triangle, and then incrementing each subsequent number by 1 as you move down the rows of the triangle. In this article, we are going to see how to display Floyd’s Triangle with the help of a Java program. But before going forward with the Java implementation, let us understand Floyd’s triangle a little more. The first row ... Read More

Java Program to Demonstrate the Call By Value

Pranay Arora
Updated on 10-Mar-2023 11:16:53

330 Views

In programming, functions often require parameters to be passed to them in order to be called or invoked. There are 2 ways to call functions, the 1st being call by Reference and the 2nd being call by value. In this article, we are going to demonstrate call by value in java. Call by value is a method in which the value of the argument is passed as a copy to the function, hence any change made to this argument inside the function will not affect the original value of the argument beyond the scope of this function. To help ... Read More

Rotate the matrix 180 degree in Java?

Mr. Satyabrata
Updated on 09-Mar-2023 12:13:59

545 Views

In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. The matrix in java is nothing but a multi-dimensional array which represents multiple rows and columns. As per the problem statement we have to rotate the given matrix to 180 degrees. It means we have to interchange the rows of the given matrix in symmetric- vertically. Let’s deep dive into this article, to know how it can be done by using Java programming language. To show you some instances Instance-1 Suppose the original matrix is { {10, 20, ... Read More

Advertisements