Object Oriented Programming Articles

Page 343 of 589

Java Program to remove the last row from a table with DefaultTableModel

Alshifa Hasnain
Alshifa Hasnain
Updated on 14-Feb-2025 756 Views

In this article, we will learn to remove the last row from a table with DefaultTableModel in Java. Managing table data dynamically is a common requirement when working with Java Swing applications. One such operation is removing the last row from a JTable using DefaultTableModel. Understanding DefaultTableModel in Java DefaultTableModel is a flexible table model in Java's Swing library that allows developers to dynamically manage table data, including adding and removing rows and columns. Provides built-in methods for adding and removing rows easily. Approach to Removing the Last Row In this program, we create a table with multiple rows and ...

Read More

Java program to check whether the number is divisible by 5

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 14-Feb-2025 4K+ Views

In mathematics, the divisibility rule of 5 states that if the number ends with 0 or 5 then it will divisible by 5. There is another way to identify the divisibility rule of 5, if the remainder comes to 0 it returns the number is divisible by 5. The mod(%) operator is normally used in programming when it comes to divisibility. Following are some examples which helps you to understand the divibility rule of 5 − Given number is 525, the number ends with 5 and it is divisible by 5. Given number is 7050, the number ends with ...

Read More

Java API documentation generator

Alshifa Hasnain
Alshifa Hasnain
Updated on 13-Feb-2025 898 Views

In this article, we will learn about Java API documentation generators. Java API documentation generators automate the process of creating structured and readable documentation for Java projects, making it easier for developers to understand and use APIs. What is a Java API Documentation Generator? A Java API documentation generator is a tool that analyzes Java source code and generates documentation in a structured format, typically HTML, XML, or Markdown. These tools extract comments and annotations from the code and transform them into comprehensive references for developers. Different Java API Documentation Generators The Following are Popular Java API documentation generators − ...

Read More

Java Program to fill elements in a float array

Nancy Den
Nancy Den
Updated on 10-Feb-2025 475 Views

In this article, we will learn how to fill elements in a float array in Java. The Arrays.fill() method is used to assign a specified value to each element of the array. Array fill() method The Arrays.fill() method in Java sets all elements of an array to a given value, making it useful for quickly initializing or resetting arrays. The Arrays.fill() method works with various data types like int, char, double, and boolean. It makes it easy to fill arrays with a default or specific value. Syntax Arrays.fill(array, value)Arrays.fill(array, start, end, value) ...

Read More

Java ResultSetMetaData getPercision() method with example

Rishi Raj
Rishi Raj
Updated on 10-Feb-2025 517 Views

In this article, we will learn how to retrieve the size of a specified column in a ResultSet object using the getPrecision() method of the ResultSetMetaData interface in JDBC. What does getPrecision() in ResultSetMetaData do? The getPercision() method of the ResultSetMetaData (interface) retrieves the size of the specified column in the current ResultSet object. This method accepts an integer value representing the index of a column and, returns an integer value representing the size of the given column. Steps to get the ResultSetMetaData object To get the ResultSetMetaData object, you need to − Step 1. Register ...

Read More

Java Program to Illustrate Use of Binary Literals

Sakshi Ghosh
Sakshi Ghosh
Updated on 28-Jan-2025 649 Views

In this article, we will learn to illustrate the use of binary literals in Java. This feature is particularly useful when working with low-level data manipulation, such as in embedded systems or when dealing with bitwise operations. What is Binary Literal? A binary literal is a number that is denoted using binary digits that are 0s and 1s. The values written in data types – byte, int, long, and short can be easily expressed in a binary number system. The prefix 0b or 0B is added to the integer to declare a binary literal. For example − ...

Read More

Java ResultSetMetaData getColumnDisplaySize() Method with Example

Alshifa Hasnain
Alshifa Hasnain
Updated on 28-Jan-2025 714 Views

In this article, we will learn the ResultSetMetaData getColumnDisplaySize() method with an example in Java. This is useful when you need to understand the display requirements of a column in a result set. Method Signature The getColumnDisplaySize(int column) method of the ResultSetMetaData class in Java retrieves the maximum width of the specified column, measured in characters. int getColumnDisplaySize(int column) Parameters: The 1-based index of the column for which you want the display size. Returns: The maximum number of characters that can be displayed for the specified column. ...

Read More

Java NumberFormat.getPercentageInstance() Method

Samual Sam
Samual Sam
Updated on 28-Jan-2025 747 Views

In this article, we will learn the NumberFormat.getPercentageInstance() method. Java provides powerful tools for formatting numbers, currencies, and percentages through the java.text.NumberFormatclass. One of the most useful methods in this class is the getPercentageInstance() method. NumberFormat.getPercentageInstance() method The NumberFormat.getPercentageInstance() method is a static method that returns a NumberFormat instance configured to format numbers as percentages. This method can be used with or without a Locale parameter.  Syntax − public static NumberFormat getPercentageInstance()public static NumberFormat getPercentageInstance(Locale locale) Without Locale: If no locale is specified, the method uses the default locale of the JVM. ...

Read More

Java ResultSet getType() Method with Example

Arushi
Arushi
Updated on 28-Jan-2025 1K+ Views

In JDBC (Java Database Connectivity), the ResultSet interface represents the result set of a database query in Java. One of the important methods provided by ResultSet is getType(), which returns the type of the ResultSet object. Result getType() method The getType() method is used to determine the type of cursor and its behavior when scrolling through the result set.Syntax of getType() int resultSet_Type = rs.getType(); This method returns an integer value that corresponds to one of the ResultSet type constants. These constants indicate the type of cursor used by the ResultSet: ResultSet.TYPE_FORWARD_ONLY (value: 1003): This ...

Read More

Get the union of two sets in Java

karthikeya Boyini
karthikeya Boyini
Updated on 28-Jan-2025 7K+ Views

The union of two sets combines all the unique elements from both sets into one. In Java we can achieve this using the HashSet class, which ensures no duplicate elements. This article will demonstrate two approaches to finding the union of two sets.  Different Approaches  Following are the two different approaches to getting the union of two sets in Java − Using the addAll() Method Using Streams Using the addAll() Method The simplest way to find the union of two sets is by using the addAll() method of the HashSet class. This ...

Read More
Showing 3421–3430 of 5,881 articles
« Prev 1 341 342 343 344 345 589 Next »
Advertisements