Arushi

Arushi

86 Articles Published

Articles by Arushi

Page 3 of 9

How to find the vowels in a given string using Java?

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

You can read a character in a String using the charAt() method. To find the vowels in a given String you need to compare every character in it with the vowel letters. Example public class FindingVowels {    public static void main(String args[]) {       String str = new String("Hi Welcome to Tutorialspoint");       for(int i=0; i

Read More

How to create a string from a Java Array?

Arushi
Arushi
Updated on 11-Mar-2026 480 Views

You can convert an array of Strings to a single array using the collect() method.Exampleimport java.util.Arrays; import java.util.stream.Collectors; public class CreatngStringFromArray {    public static void main(String args[]) {       String [] myArray = {"Welcome", "to", "Tutorialspoint"};       String str = Arrays.stream(myArray).collect(Collectors.joining(" "));       System.out.println(str);    } }OutputWelcome to Tutorialspoint

Read More

Class declaration with a method that has a parameter in Java

Arushi
Arushi
Updated on 11-Mar-2026 256 Views

A class declaration can contain a method that has a parameter in Java. A program that demonstrates this is given as follows:Exampleclass Message {    public void messagePrint(String msg) {       System.out.println("The message is: " + msg);    } } public class Demo { public static void main(String args[]) { Message m = new Message(); m.messagePrint("Java is fun"); } }OutputThe message is: Java is funNow let us understand the above program.The Message class is created with a single member function ...

Read More

How to extend Interfaces in Java

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

An interface contains variables and methods like a class but the methods in an interface are abstract by default unlike a class. An interface extends another interface like a class implements an interface in interface inheritance.A program that demonstrates extending interfaces in Java is given as follows:Exampleinterface A {    void funcA(); } interface B extends A {    void funcB(); } class C implements B {    public void funcA() {       System.out.println("This is funcA");    }    public void funcB() {       System.out.println("This is funcB");    } } public class Demo {    public ...

Read More

A static initialization block in Java

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

Instance variables are initialized using initialization blocks. However, the static initialization blocks can only initialize the static instance variables. These blocks are only executed once when the class is loaded. There can be multiple static initialization blocks in a class that is called in the order they appear in the program.A program that demonstrates a static initialization block in Java is given as follows:Examplepublic class Demo {    static int[] numArray = new int[10];    static {       System.out.println("Running static initialization block.");       for (int i = 0; i < numArray.length; i++) {       ...

Read More

Class that contains a String instance variable and methods to set and get its value in Java

Arushi
Arushi
Updated on 11-Mar-2026 600 Views

A class declaration can contain a String instance and methods to set and get its value in Java.A program that demonstrates this is given as follows:Exampleclass Name {    private String name;    public void setName(String n) {       name = n;    }    public String getName() {       return name;    } } public class Demo {    public static void main(String[] args) {       Name n = new Name();       n.setName("John Smith");       System.out.println("The name is: " + n.getName());    } }OutputThe name is: John SmithNow let ...

Read More

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 585 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 157 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
Showing 21–30 of 86 articles
« Prev 1 2 3 4 5 9 Next »
Advertisements