Found 9326 Articles for Object Oriented Programming

Java Program to Open the given URL in System Default Browser in Windows

Saba Hilal
Updated on 23-Mar-2023 12:37:46

4K+ Views

There are different ways of viewing web pages in a browser using URL. Here, the methods of doing the same are specified using the Java code. The given URL is first entered by using the Java program. Then the related Webpage is opened in the default browser. This article uses three different approaches for opening the webpage as specified by the URL in the browser through the Java code. Multiple Approaches For these programs, the displaying of the given URL is done using two different approaches. By Using desktop.browse(uri) for the object belonging to Desktop class. By Using javafx ... Read More

Java Program to Print Swastika By Taking Input from User

Saba Hilal
Updated on 23-Mar-2023 12:34:37

666 Views

Here, two different approaches are used for making this design using Java. In both approaches, the size of the Swastika is decided by the user. The user provides the input for the table or frame size. The Swastika is often used as an example to learn rows, column and tabular layout concepts using different languages including java. Swastika is a religious symbol of Hinduism, Buddhism and Jainism. Making Swastika using Java. Here, three different approaches are used for making this design using Java. Multiple Approaches The given problem would be solved by three distinct approaches. By using two ... Read More

Java Program to open the Command Prompt and Insert commands

Saba Hilal
Updated on 24-Jun-2024 15:53:26

4K+ Views

This article uses various approaches for selecting the commands inserted in the opened command window through the Java code. The command window is opened by using ‘cmd’. Here, the methods of doing the same are specified using Java code. The Command window is first opened using the Java program. It is opened as a child process. If the java program is run in an existing cmd window, another one is opened as a new process. Further, different types of commands are inserted and executed in that opened command window via the java code. These programs may not work in ... Read More

Java Program to Read a Large Text File Line By Line

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

455 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

685 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

497 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

341 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

876 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

Advertisements