Showing posts with label JDBC. Show all posts
Showing posts with label JDBC. Show all posts

April 24, 2016

#Java: Part 14-How does substring() inside String works?

Substring creates a new object out of source string by taking a portion of the original string. It is defined in defined in java.lang.String class.

substring() has two variants:-
  • substring(int beginIndex): returns the substring starting from the specified index. The beginIndex is inclusive. This method throws IndexOutOfBoundsException if the beginIndex is less than zero or greater than the length of String.
  • substring(int beginIndex, int endIndex): returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex – 1. Thus the length of the substring is endIndex-beginIndex (beginIndex is inclusive and endIndex is exclusive while getting the substring).
If beginIndex is equal to length in substring(int beginIndex) it won't throw IndexOutOfBoundException instead it will return empty String. Same is the case when beginIndex and endIndex is equal.

#Java: Part 13 JDBC Interview Questions And Answers

> > Part 12 Serialization Interview Questions and Answers for Experienced Developers

What is JDBC?
JDBC (Java Database Connectivity) is a Java API that is used to connect and execute query to the database. JDBC API uses jdbc drivers to connects to the database.