Found 7442 Articles for Java

Is RowSet Scrollable? Explain with an example?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

491 Views

A RowSet object is similar to ResultSet, it also stores tabular data, in addition to the features of a ResultSet. A RowSet follows the JavaBeans component model.If you Retrieve a ResultSet object by default the cursor of it moves only in forward direction. i.e. you can retrieve the contents of it from first to last.But, in a scrollable result set, the cursor can scroll forward and backward and you can retrieve data backward too.To make ResultSet object scrollable, you need to create one as shown below −Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);Whereas, a RowSet object is Scrollable by default. Therefore, whenever ... Read More

What is RowSet? How to retrieve contents of a table using RowSet? Explain?

Samual Sam
Updated on 30-Jul-2019 22:30:25

1K+ Views

A RowSet object is similar to ResultSet, it also stores tabular data, in addition to the features of a ResultSet a RowSet follows JavaBeans component model. This can be used as a JavaBeans component in a visual Bean development environment, i.e. in environments like IDE’s you can visually manipulate these properties.Connecting RowSet with databaseThe RowSet interface provides methods to set Java bean properties to connect it to the required database −void setURL(String url):void setUserName(String user_name):void setPassword(String password):PropertiesA RowSet object contains properties and each property have Setter and getter methods. Using these you can set and get values from a command ... Read More

Default virtual behavior in C++ vs Java

Aman Kumar
Updated on 16-May-2025 17:05:01

222 Views

The default behaviour of virtual functions in C++ and Java is significantly different, especially in terms of the handling of method overriding and polymorphism. Default Virtual Behavior in C++ C++ methods are non-virtual by default. To enable dynamic polymorphism, the virtual keyword must be explicitly used in the base class when defining a method. If virtual is not given, the method call is handled at compile time using the object of static type. Example In this example, we implement the default behaviour of the virtual function in C++: #include using namespace std; class Base { public: void nonVirtualMethod() { cout

IntStream summaryStatistics() method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

610 Views

The summaryStatistics() method in the IntStream class is used to return summary data about the elements of this stream. The syntax is as follows:IntSummaryStatistics summaryStatistics()Create an IntStream and add some elements:IntStream intStream = IntStream.of(30, 60, 90);Now, get the summary data about the above elements:IntSummaryStatistics details = intStream.summaryStatistics();The following is an example to implement IntStream summaryStatistics() method in Java:Example Live Demoimport java.util.stream.IntStream; import java.util.IntSummaryStatistics; public class Demo {    public static void main(String[] args) {       IntStream intStream = IntStream.of(30, 60, 90);       IntSummaryStatistics details = intStream.summaryStatistics();       System.out.println("Details = "+details);    } }OutputDetails = IntSummaryStatistics{count=3, ... Read More

How to generate Infinite Stream of Integers in Java using IntStream.iterate()

Nancy Den
Updated on 30-Jul-2019 22:30:25

221 Views

To generate an infinite stream of integer, use the IntStream.iterate(). The method is used to iterator an IntStream.Import the following package for the IntStream class in Java:import java.util.stream.IntStream;The following is an example displaying how to generate Infinite Stream of Integers with IntStream.iterate() in Java:Exampleimport java.util.stream.IntStream; public class Main {    public static void main(String[] args) {       IntStream.iterate(0, k -> k + 2).forEach(System.out::println);    } }Here is the output that displays integers infinitely:0 2 4 6 8 10 12 . . .

The build() method in Java Stream.Builder

Nancy Den
Updated on 30-Jul-2019 22:30:25

5K+ Views

The build() method in Stream.Builder class is used to build the stream. It returns the built stream.The syntax is as follows:Streaml build()Import the following package for the Stream.Builder class in Java:import java.util.stream.Stream;Declare a Stream.Builder:Stream.Builder builder = Stream.builder();Add some elements in the stream:builder.add("One"); builder.add("Two"); builder.add("Three");Now, use the build() method:Stream str = builder.build();The following is an example displaying how to implement build() method of Stream.Builder in Java:Example Live Demoimport java.util.stream.Stream; public class Demo {    public static void main(String[] args) {       Stream.Builder builder = Stream.builder();       builder.add("One");       builder.add("Two");       builder.add("Three");       ... Read More

DoubleStream count() method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

169 Views

The count() method of the DoubleStream class returns the count of the elements in the stream.The syntax is as follows:long count()To use the DoubleStream class in Java, import the following package:import java.util.stream.DoubleStream;Create DoubleStream and add some elements:DoubleStream doubleStream = DoubleStream.of(50.8, 67.9, 35.7, 23.6, 89.9);Now, get the count of elements in the DoubleStream:long res = doubleStream.count();The following is an example to implement DoubleStream count() method in Java:Example Live Demoimport java.util.stream.DoubleStream; public class Demo {    public static void main(String[] args) {       DoubleStream doubleStream = DoubleStream.of(50.8, 67.9, 35.7, 23.6, 89.9);       long res = doubleStream.count();       ... Read More

DoubleStream min() method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

132 Views

The min() method of the DoubleStream class returns an OptionalDouble describing the minimum element of this stream, or an empty OptionalDouble if this stream is empty.The syntax is as follows:OptionalDoublemin()Here, OptionalDouble is a container object which may or may not contain a double valueTo use the DoubleStream class in Java, import the following package:import java.util.stream.DoubleStream;Create a DoubleStream and add elements to the stream:DoubleStream doubleStream = DoubleStream.of(67.9, 89.9, 10.5, 95.8, 49.6);Get the maximum element from the DoubleStream:OptionalDouble res = doubleStream.max();The following is an example to implement DoubleStream min() method in Java:Example Live Demoimport java.util.OptionalDouble; import java.util.stream.DoubleStream; public class Demo {    public ... Read More

LongStream min() method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

143 Views

The min() method of the LongStream class in Java returns an OptionalLong describing the minimum element of this stream, or an empty optional if this stream is empty.The syntax is as follows:OptionalLong min()Here, OptionalLong is a container object which may or may not contain a long value.To use the LongStream class in Java, import the following package:import java.util.stream.LongStream;The following is an example to implement LongStream min() method in Java. The isPresent() method of the OptionalLong class returns true if the value is present:Example Live Demoimport java.util.*; import java.util.stream.LongStream; public class Demo {    public static void main(String[] args) {     ... Read More

IntStream sequential() method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

444 Views

The sequential() method of the IntStream class in Java is used to return a sequential IntStream. The syntax is as follows:IntStream sequential()First, create an IntStream and elements in a range using the range() method:IntStream intStream1 = IntStream.range(11, 21);Now, for a sequential IntStream, use the sequential() method like this:IntStream intStream2 = intStream1.sequential();The following is an example to implement IntStream sequential() method in Java:Example Live Demoimport java.util.*; import java.util.stream.IntStream; public class Demo {    public static void main(String[] args) {       IntStream intStream1 = IntStream.range(11, 21);       IntStream intStream2 = intStream1.sequential();       intStream2.forEach(System.out::println);    } }Output11 12 ... Read More

Advertisements