Found 9321 Articles for Object Oriented Programming

Java Program to Read a Large Text File Line By Line

Saba Hilal
Updated on 23-Mar-2023 12:06:38

464 Views

This article includes the way to read text files line by line. Here, the three different methods are explained with examples. Storing a file in text format is important especially when data from one structured /unstructured form is transferred to another form. Therefore, basic file transfer systems integrate the txt file reading and writing process as their application components. Therefore, how to use text file reading and writing methods is also important for making the parsers. Multiple Approaches The given problem statement is solved in three different approaches By using the BufferedReader class By using the FileInputStream By using ... Read More

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

508 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

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

How to send button value to PHP backend via POST using ajax?

Mohit Panchasara
Updated on 10-Mar-2023 16:56:27

2K+ Views

AJAX (Asynchronous JavaScript and XML) makes web pages more responsive, interactive, and dynamic by enabling server communication without requiring a page to load. JavaScript is used to send and receive data from a server using various technologies, including XML, JSON, and HTML. In these, JSON is the most popular. AJAX is frequently used to transmit information from a web page to a server-side script, like a PHP script. The XMLHttpRequest object, included in most contemporary web browsers, can be used for this. You can establish a connection to a given URL, send data to that URL, and then wait ... Read More

Advertisements