Java Articles

Page 181 of 450

Java program to demonstrate the call by value

Pranay Arora
Pranay Arora
Updated on 11-Nov-2024 975 Views

In programming, functions often require parameters to be passed to them 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 understand these concepts ...

Read More

Difference between Groovy and Java

Aishwarya Naglot
Aishwarya Naglot
Updated on 11-Nov-2024 1K+ Views

Programmers have been using scripting languages for quite some time. When it comes to Linux and Unix computers, scripting languages were mostly utilised for things like scripting tasks that automate platform customizations, software installations, and one-shot command line jobs with bash scripts. Groovy is an authentically creative language that runs on the same virtual machine as Java. Hence, it can interact with Java in a way that is both efficient and effective. Despite the fact that Java is one of the most popular and commonly used programming languages for producing content for the web, certain activities, such as file handling ...

Read More

Java program to read a large text file line by line

Saba Hilal
Saba Hilal
Updated on 08-Nov-2024 842 Views

This article includes the way to read text files line by line in Java. 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 ...

Read More

Java program to print unique values from a list

AmitDiwan
AmitDiwan
Updated on 08-Nov-2024 2K+ Views

In this article, we will learn to print unique values from a List in Java. This program will use a loop-based approach to identify and display only the values that appear once, skipping any duplicates. This approach is helpful when working with datasets where you want to remove repeated items and focus on distinct entries. Problem Statement Write a program in Java to print unique values from a list. Below is a demostration of the same − Input 55, 67, 99, 11, 54, 55, 88, 99, 1, 13, 45 Output The distinct elements in the array are 55 67 99 11 ...

Read More

Java program to add period to LocalDate

Nancy Den
Nancy Den
Updated on 08-Nov-2024 798 Views

In this program, we will learn to add a specific period to a date using Java’s LocalDate class. By using Java's Period class, we can specify an amount of time (such as months and days) and then add this period to a LocalDate. The program demonstrates how to set a period and apply it to a given date to get a new, updated date. Steps to add Period to LocalDate  Following are the steps to add Period to LocalDate − Import LocalDate and Period from java.time package to work with dates and periods. ...

Read More

Java DatabaseMetaData supportsGroupBy() method with example

Rishi Raj
Rishi Raj
Updated on 08-Nov-2024 218 Views

In this article, we will learn how to check whether a database supports the SQL GROUP BY clause using JDBC in Java. The GROUP BY clause is used to organize identical data into groups in SQL queries, typically following the WHERE clause and preceding the ORDER BY clause. With JDBC, we can determine whether the underlying database supports this clause using the supportsGroupBy() method of the DatabaseMetaData interface. Problem StatementGiven a MySQL database, write a Java program that connects to the database and checks if the database supports the SQL GROUP BY clause.Input Database connection URL, username, and ...

Read More

Java DatabaseMetaData getMaxStatements() method with example.

Smita Kapse
Smita Kapse
Updated on 08-Nov-2024 212 Views

In this article, we will learn how to retrieve the maximum number of open statements allowed by a database using the DatabaseMetaData interface in Java. The getMaxStatements() method of the DatabaseMetaData interface is used to find out the maximum number of open statements (objects) that the underlying database allows at one time. This method returns an integer value, representing the maximum number of statements that are allowed to be open at a time. If this value is 0 it indicates that there is no limit or, the limit is unknown. Problem StatementGiven a connection to a database, write a ...

Read More

Java DataBaseMetaData getMaxCatalogNameLength() method with example.

Smita Kapse
Smita Kapse
Updated on 07-Nov-2024 141 Views

In this article, we will learn how to retrieve the maximum number of characters allowed in a catalog name using the getMaxCatalogNameLength() method in Java. This method belongs to the DatabaseMetaData interface, which provides comprehensive information about the database, including its structure and capabilities. The method is useful for understanding the limitations imposed by the underlying database in terms of catalog name length. Problem StatementGiven a connection to a database, write a Java program to retrieve and display the maximum number of characters that the database allows for catalog names using the getMaxCatalogNameLength() method.Input A MySQL database connection URL, ...

Read More

Length of longest balanced parentheses prefix using Java

Sourav Sarkar
Sourav Sarkar
Updated on 07-Nov-2024 268 Views

In this article we will explore how we can find the length of longest balanced parentheses prefix using java , first we will understand the problem with some examples then we learn two different approaches to find it. Problem Statement Here, we will be given a string with parentheses and we need to find the length of balanced parentheses set from the string i.e. for every open parentheses "(" if there is a close parentheses ")", then we call it balanced. Prefix defines the first balanced set from the string, let the parenthesis set '(())()' we consider only '(())' Input ...

Read More

Java program to find the number occurring odd number of times

AmitDiwan
AmitDiwan
Updated on 07-Nov-2024 689 Views

In this article, we will learn how to find the number in an array that appears an odd number of times using Java. By looping through the array and counting occurrences of each number, the program will detect and return the one with an odd frequency. Problem Statement Given an array identify the integer that occurs an odd number of times. Below is the demostration of the same − Input 34, 56, 99, 34, 55, 99, 90, 11, 12, 11, 11, 34 Output The number that occurs odd number of times in the array is 34 Steps to find the number occurring ...

Read More
Showing 1801–1810 of 4,498 articles
« Prev 1 179 180 181 182 183 450 Next »
Advertisements