Arushi

Arushi

86 Articles Published

Articles by Arushi

Page 2 of 9

Print a Vector in a comma-delimited list, in index order and surrounded by square brackets ([]) in Java

Arushi
Arushi
Updated on 11-Mar-2026 563 Views

A Vector can be printed in a comma-delimited list, in index order and surrounded by square brackets ([]) by simply using System.out.println() along with the Vector object.A program that demonstrates this is given as follows −Exampleimport java.util.Vector; public class Demo {    public static void main(String args[]) {       Vector vec = new Vector(5);       vec.add(4);       vec.add(1);       vec.add(3);       vec.add(9);       vec.add(6);       System.out.println(vec);    } }The output of the above program is as follows −[4, 1, 3, 9, 6]Now let us understand the ...

Read More

Use a quantifier to find a match in Java

Arushi
Arushi
Updated on 11-Mar-2026 148 Views

One of the quantifiers is the plus(+). This matches one or more of the subsequence specified with the sequence.A program that demonstrates using the quantifier plus(+) to find a match in Java is given as follows:Exampleimport java.util.regex.Matcher; import java.util.regex.Pattern; public class Demo {    public static void main(String args[]) {       Pattern p = Pattern.compile("o+");       Matcher m = p.matcher("o oo ooo");       System.out.println("The input string is: o oo ooo");       System.out.println("The Regex is: o+ ");       System.out.println();       while (m.find()) {          System.out.println("Match: " ...

Read More

Multiple inheritance by Interface in Java

Arushi
Arushi
Updated on 11-Mar-2026 86K+ Views

An interface contains variables and methods like a class but the methods in an interface are abstract by default unlike a class. Multiple inheritance by interface occurs if a class implements multiple interfaces or also if an interface itself extends multiple interfaces.A program that demonstrates multiple inheritance by interface in Java is given as follows:Exampleinterface AnimalEat {    void eat(); } interface AnimalTravel {    void travel(); } class Animal implements AnimalEat, AnimalTravel {    public void eat() {       System.out.println("Animal is eating");    }    public void travel() {       System.out.println("Animal is travelling");    } ...

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

Java sql.Date setTime() method with example.

Arushi
Arushi
Updated on 29-Sep-2024 1K+ Views

In this program, we will connect to a MySQL database using JDBC, insert a new record into the dispatches table, and retrieve all records from the table. The setTime() method from Date class of java.util package that accepts a variable of long type, representing the number of milliseconds from the epoch time (January 1, 1970, 00:00:00.000 GMT) to the required time, and sets the specified time value to the current Date object. //Setting time date.setTime(time_value_in_long); The goal of the program is to demonstrate how to interact with a database using JDBC and handle Date and Time objects in Java. ...

Read More

Java Connection getClientInfo() method with example

Arushi
Arushi
Updated on 19-Sep-2024 2K+ Views

In this article, we will learn how to retrieve and set client information properties in a MySQL database connection using the getClientInfo() method from the Connection interface in JDBC. The program demonstrates how to establish a connection to a database, set custom user credentials as client information properties, and then retrieve and display those values. Steps to use the Java Connection getClientInfo() method Following are the steps to use the Java Connection getClientInfo() method − Register the MySQL driver using the DriverManager.registerDriver() method. Establish a connection to the MySQL database using DriverManager.getConnection(). ...

Read More

Java Connection getMetaData() method with example

Arushi
Arushi
Updated on 02-Aug-2024 2K+ Views

Generally, Data about data is known as metadata. The DatabaseMetaData interface provides methods to get information about the database you have connected with like, database name, database driver version, maximum column length, etc... The getMetaData() method of the Connection interface retrieves and returns the DatabaseMetaData object. This contains information about the database you have connected to. You can get information about the database such as the name of the database, version, driver name, user name, URL, etc… by invoking the methods of the DatabaseMetaData interface using the obtained object. This method returns the DatabaseMetaData object which holds information about the underlying ...

Read More

Java Connection setTransactionIsolation() method with example

Arushi
Arushi
Updated on 05-Jul-2024 3K+ Views

In a database system, where more than one transaction is being executed simultaneously and in parallel, the property of isolation states that all the transactions will be carried out and executed as if it is the only transaction in the system. No transaction will affect the existence of any other transaction. Transaction Isolation Levels in Java Connection JDBC (Java Database Connectivity) provides support 5 transaction isolation levels through Connection interface. TRANSACTION_NONE: It is represented by integer value 0 does not support transactions. TRANSACTION_READ_COMMITTED: It is represented by integer value 2 supports ...

Read More

Java ResultSet next() method with example

Arushi
Arushi
Updated on 31-May-2024 26K+ Views

When we execute certain SQL queries (SELECT query in general) they return tabular data.The java.sql.ResultSet interface represents such tabular data returned by the SQL statements.i.e. the ResultSet object holds the tabular data returned by the methods that execute the statements which quires the database (executeQuery() method of the Statement interface in general).The ResultSet object has a cursor/pointer which points to the current row. Initially this cursor is positioned before first row.The next() method of the ResultSet interface moves the pointer of the current (ResultSet) object to the next row, from the current position.Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("Select ...

Read More

How to reverse of integer array in android listview?

Arushi
Arushi
Updated on 26-Jun-2020 457 Views

This example demonstrate about How to reverse of integer array in android listview.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml         In the code, we have taken listview to show reversed arrayStep 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ListView; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; public class MainActivity extends AppCompatActivity {    ListView list;    int[] ...

Read More
Showing 11–20 of 86 articles
« Prev 1 2 3 4 5 9 Next »
Advertisements