Object Oriented Programming Articles

Page 352 of 589

How to use Class in Node?

Moksh Gupta
Moksh Gupta
Updated on 12-Nov-2024 443 Views

Introduction Node.js is trending as an environment where different efficient and logical applications are executed at the moment. One of them is extending modern JS syntax, for example,  classes, which makes OOP in Node.js more possible to use and improve. Scroll down to learn what a class is in Node.js, how one can be defined, how methods can/must be added, subclass/superclass in Node.js, and some uses of classes in Node.js. What is a Class in Node.js? A class is a blueprint of objects that have certain characteristics and behaviors or actions. Classes were introduced in ECMAScript 2015 ( ES6) as ...

Read More

Create a Date object using the Calendar class in Java

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

In Java, we can create a date object using the calendar class, which gives us more control on date and time. We will discuss the process in this article. What is the Calendar class? In order to understand the usage of we must know what is the calendar class. The Calendar class allows us to work with date and time more easily than Date class. like, we can set specific parts of the date, like month, year, and day. For using Calendar class, import the following package. import java.util.Calendar; Now, let us create an object of Calendar class. Calendar ...

Read More

Java program to demonstrate the call by value

Pranay Arora
Pranay Arora
Updated on 11-Nov-2024 967 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

Java program to read a large text file line by line

Saba Hilal
Saba Hilal
Updated on 08-Nov-2024 841 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 212 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 211 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 139 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

Java program to sort a HashMap by Keys and Values

Way2Class
Way2Class
Updated on 07-Nov-2024 2K+ Views

In this article, we will learn the procedures for sorting a HashMap in Java by its keys and values, as well as examine the performance implications associated with each technique. HashMap, a frequently employed data structure, enables programmers to store key-value pairs. This data structure is an exceedingly efficient method for storing data and allows for swift value retrieval based on keys. However, on occasion, it may become necessary to arrange the HashMap by its keys or values.  Different Approaches of Sorting the HashMap Following are the different approaches to sorting a HashMap by Keys and Values − ...

Read More
Showing 3511–3520 of 5,881 articles
« Prev 1 350 351 352 353 354 589 Next »
Advertisements