
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

1K+ Views
In this section, we will see how to convert C++ string (std::string) to const char* or char*. These formats are C style strings. We have a function called c_str(). This will help us to do the task. It returns a pointer to an array that contains a null-terminated sequence of characters (i.e., a C-string) representing the current value of the string object.Following is the declaration for std::string::c_str.const char* c_str() const;This function returns a pointer to an array that contains a null-terminated sequence of characters (i.e., a C-string) representing the current value of the string object. If an exception is thrown, ... Read More

6K+ Views
A. You can create a table in a database using the CREATE TABLE query.SyntaxCREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype, ..... columnN datatype, PRIMARY KEY( one or more columns ) );To create a table in a database using JDBC API you need to:Register the driver: Register the driver class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as parameter.Establish a connection: Connect ot the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) as parameters to it.Create Statement: Create a Statement object using the createStatement() ... Read More

4K+ Views
In C++ we can compare two strings using compare() function and the == operator. Then the question is why there are two different methods? Is there any difference or not? Yes, there are some basic differences between compare() and == operator. In C++ the == operator is overloaded for the string to check whether both strings are same or not. If they are the same this will return 1, otherwise 0. So it is like Boolean type function. The compare() function returns two different things. If both are equal, it will return 0, If the mismatch is ... Read More

363 Views
A. You can drop/delete a database using the DROP DATABASE query.SyntaxDROP DATABASE DatabaseName;To drop a Database using JDBC API you need to:Register the driver: Register the driver class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as parameter.Establish a connection: Connect ot the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) as parameters to it.Create Statement: Create a Statement object using the createStatement() method of the Connection interface.Execute the Query: Execute the query using the execute() method of the Statement interface.ExampleThe show databases command gives ... Read More

831 Views
In C++, char[] represents a character array, while string is a class in STL to manage text data. Both string and char[] can be used to store and process text data. But, they are different in terms of structure, usage, memory management, and capabilities. In this article, we will discuss the difference between string and char[] types in C++. char[] in C++ char[] is an array of characters that is used to store a string. It is a C-style string representation. The size of char array will be fixed. At the end of the array, a null character '\0' ... Read More

632 Views
In C++, we can create vectors easily using the standard library. We are taking the main string and the string that will be searched as a vector, then searching it into the main string. When one match is found the function returns the address, and removes it from the main string. So in the next iteration, it starts from location 0 and searches again. For multiple occurrences, we are using loops and repeatedly searching for the match, and return the position. Input: Main String: "ABCcdABCcdABC" Substring to search: "cd" Output: Match found at Position = 1 Match found at ... Read More

496 Views
In general, You can change the current database in MySQL using the USE query.SyntaxUse DatabaseName;To change the current database using JDBC API you need to:Register the driver: Register the driver class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as parameter.Establish a connection: Connect ot the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) as parameters to it.Create Statement: Create a Statement object using the createStatement() method of the Connection interface.Execute the Query: Execute the query using the execute() method of the Statement interface.ExampleFollowing JDBC ... Read More

2K+ Views
A. In general, you can create a database using the CREATE DATABASE query.SyntaxCREATE DATABASE DatabaseName;To create a Database using JDBC API you need to:Register the driver: Register the driver class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as parameter.Establish a connection: Connect ot the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) as parameters to it.Create Statement: Create a Statement object using the createStatement() method of the Connection interface.Execute the Query: Execute the query using the execute() method of the Statement interface.Example:Following JDBC program ... Read More

133 Views
To add elements to the ArrayBlockingQueue class, use the add() method.The syntax is as follows:boolean add(E ele)Here, ele is the element to be added to the queue.To work with ArrayBlockingQueue class, you need to import the following package:import java.util.concurrent.ArrayBlockingQueue;The following is an example to add elements in Java ArrayBlockingQueue class:Example Live Demoimport java.util.concurrent.ArrayBlockingQueue; public class Demo { public static void main(String[] args) { ArrayBlockingQueue q = new ArrayBlockingQueue(7); q.add(100); q.add(250); q.add(300); q.add(450); q.add(550); q.add(600); q.add(700); ... Read More

183 Views
To return a shallow copy of the CopyOnWriteArrayList, use the clone() method.The syntax is as follows:public Object clone()To work with CopyOnWriteArrayList class, you need to import the following package:import java.util.concurrent.CopyOnWriteArrayList;The following is an example to implement CopyOnWriteArrayList class clone() method in Java:Example Live Demoimport java.util.concurrent.CopyOnWriteArrayList; public class Demo { public static void main(String[] args) { CopyOnWriteArrayList arrList = new CopyOnWriteArrayList(); arrList.add(30); arrList.add(90); arrList.add(80); arrList.add(70); arrList.add(90); arrList.add(100); arrList.add(120); System.out.println("CopyOnWriteArrayList = " + arrList); System.out.println("Cloned CopyOnWriteArrayList = " + arrList.clone()); } }OutputCopyOnWriteArrayList = [30, 90, 80, 70, 90, 100, 120] Cloned CopyOnWriteArrayList = [30, 90, 80, 70, 90, 100, 120]