Krantik Chavan has Published 278 Articles

Java Program to get Tail Set from TreeSet

Krantik Chavan

Krantik Chavan

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

92 Views

Let us first create a TreeSet and add elements to it:TreeSet treeSet = new TreeSet(); treeSet.add(20); treeSet.add(50); treeSet.add(100); treeSet.add(120); treeSet.add(150); treeSet.add(200); treeSet.add(250); treeSet.add(300); treeSet.add(350); treeSet.add(400);Now, let us get Tail Set from the TreeSet. In the below case, we will get elements above 200:SortedSet set = treeSet.tailSet(200);Exampleimport java.util.SortedSet; import java.util.TreeSet; public ... Read More

What is TYPE_SCROLL_INSENSITIVE ResultSet in JDBC?

Krantik Chavan

Krantik Chavan

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

2K+ Views

This represents a scrollable ResultSet i.e. the cursor moves in forward or backward directions. This type of ResultSet is insensitive to the changes that are made in the database i.e. the modifications done in the database are not reflected in the ResultSet.Which means if we have established a connection with ... Read More

Java Program to convert LocalDateTime to LocalDate and LocalTime

Krantik Chavan

Krantik Chavan

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

4K+ Views

At first set a LocalDateTime:LocalDate date = LocalDate.now(); LocalTime time = LocalTime.now(); LocalDateTime dateTime = LocalDateTime.of(date, time);Now, convert the LocalDateTime to LocalDate and LocalTime:LocalDate localDate = LocalDateTime.now().toLocalDate(); LocalTime localTime = LocalDateTime.now().toLocalTime();Exampleimport java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; public class Demo {    public static void main(String[] args) {       ... Read More

What is TYPE_SCROLL_SENSITIVE ResultSet in JDBC?

Krantik Chavan

Krantik Chavan

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

4K+ Views

This represents is a scrollable ResultSet i.e. the cursor moves in forward or backward directions. This type of ResultSet is sensitive to the changes that are made in the database i.e. the modifications done in the database are reflected in the ResultSet.Which means if we have established a connection with ... Read More

How to format and display date in Java as '201904'

Krantik Chavan

Krantik Chavan

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

110 Views

To format and display date like this i.e. YearMonth, you need to set the pattern:uuuuMMAt first, set a LocalDate:LocalDate localDate = LocalDate.now();Now format and display date as ‘201904’:localDate.format(DateTimeFormatter.ofPattern("uuuuMM"))Exampleimport java.time.LocalDate; import java.time.format.DateTimeFormatter; public class Demo {    public static void main(String[] args) {       LocalDate localDate = LocalDate.now();   ... Read More

How can I display Java date as '12/04/2019'

Krantik Chavan

Krantik Chavan

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

85 Views

To format and display date like this i.e. Day/Month/Year, you need to set the pattern:dd/MM/yyyyAt first, set a LocalDate:LocalDate localDate = LocalDate.now();Now format and display date as '12/04/2019':localDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy"))Exampleimport java.time.LocalDate; import java.time.format.DateTimeFormatter; public class Demo {    public static void main(String[] args) {       LocalDate date = LocalDate.now();   ... Read More

Network Control Protocol (NCP)

Krantik Chavan

Krantik Chavan

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

4K+ Views

Network Control Protocol (NCP) is a set of protocols forming a part of Point − to − Point Protocol (PPP). PPP is a data link layer protocol that is used to transmit multiprotocol data between two directly connected (point-to-point) computers. PPP is composed of link control protocol (LCP), authentication protocol ... Read More

What is the difference between the TYPE_SCROLL_INSENSITIVE and TYPE_SCROLL_SENSITIVE ResultSets in JDBC?

Krantik Chavan

Krantik Chavan

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

2K+ Views

In the TYPE_SCROLL_INSENSITIVE ResultSet, the cursor moves in forward or backward directions. This type of ResultSet is insensitive to the changes that are made in the database i.e. the modifications done in the database are not reflected in the ResultSet.Which means if we have established a connection with a database ... Read More

Java Program to convert a list to a read-only list

Krantik Chavan

Krantik Chavan

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

217 Views

Let’s say the following is our list which isn’t read-only:List < Integer > list = new ArrayList < Integer > (); list.add(10); list.add(20); list.add(30); list.add(40); list.add(50); list.add(20); list.add(40); list.add(50);Convert the above list to Read-only:list = Collections.unmodifiableList(list);On conversion, now you won’t be add or remove elements from the List. Let us ... Read More

What is Payload in Computer Network?

Krantik Chavan

Krantik Chavan

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

6K+ Views

In computer networking and telecommunications, when a transmission unit is sent from the source to the destination, it contains both a header and the actual data to be transmitted. This actual data is called the payload. The header contains the protocol information as well as the source and destination addresses, ... Read More

Advertisements