- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Samual Sam has Published 2492 Articles
Samual Sam
675 Views
Use the singleton design pattern. Here is the Java code that returns a single object −ConnectDatabase.javaimport java.sql.Connection; import java.sql.DriverManager; public class ConnectDatabase { static Connection conn = null; public static Connection getConnection() { if (conn != null) return conn; String database = ... Read More
Samual Sam
83 Views
A new FloatBuffer can be allocated using the method allocate() in the class java.nio.FloatBuffer. This method requires a single parameter i.e. the capacity of the buffer. It returns the new FloatBuffer that is allocated. If the capacity provided is negative, then the IllegalArgumentException is thrown.A program that demonstrates this is ... Read More
Samual Sam
59 Views
The algorithm name for the key pair generator can be obtained using the method getAlgorithm() in the class java.security.KeyPairGenerator. This method requires no parameters and it returns the algorithm name for the key pair generator.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class ... Read More
Samual Sam
58 Views
An immutable copy of a duration where the required duration is multiplied by a value can be obtained using the method multipliedBy() in the Duration class in Java. This method requires a single parameter i.e. the value which is to be multiplied and it returns the immutable copy of the ... Read More
Samual Sam
48 Views
Consider including the following properties for an attribute −S.No.Property & Purpose1nameThe name element defines the name of an attribute. Each attribute name must be unique for a particular tag.2requiredThis specifies if this attribute is required or is an optional one. It would be false for optional.3rtexprvalueDeclares if a runtime expression ... Read More
Samual Sam
360 Views
The fn:indexOf() function returns the index within a string of a specified substring.SyntaxThe fn:indexOf() function has the following syntax −int indexOf(java.lang.String, java.lang.String)ExampleFollowing is the example to explain the functionality of the fn:indexOf() function − Using JSTL Functions ... Read More
Samual Sam
219 Views
To reserve MySQL auto-incremented IDs, the syntax is as follows −START TRANSACTION; insert into yourTableName values(), (), (), (); ROLLBACK; SELECT LAST_INSERT_ID() INTO @anyVariableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table reservingAutoIncrementDemo -> ( ... Read More
Samual Sam
59 Views
The offset of the first element of the buffer inside the buffer array is obtained using the method arrayOffset() in the class java.nio.FloatBuffer. If the buffer backed by the array is read-only, then the ReadOnlyBufferException is thrown.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; ... Read More
Samual Sam
47 Views
An immutable copy of a duration where some milliseconds are added to it can be obtained using the plusMillis() method in the Duration class in Java. This method requires a single parameter i.e. the number of milliseconds to be added and it returns the duration with the added milliseconds.A program ... Read More
Samual Sam
496 Views
Null pointer is a pointer which points nothing.Some uses of null pointer are:b) To initialize a pointer variable when that pointer variable isn’t assigned any valid memory address yet.b) To pass a null pointer to a function argument when we don’t want to pass any valid memory address.c) To check ... Read More