- 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
Found 9313 Articles for Object Oriented Programming
5K+ Views
You can typecast with the help of method intValue(). The syntax is as follows −Integer yourVariableName=((BigInteger) yourBigIntegerValue).intValue();Here is the Java code to convert java.math.BigInteger cast to java.lang.Integer. The code is as follows −Example Live Demoimport java.math.BigInteger; public class BigIntegerToInteger { public static void main(String []args) { BigInteger bigValue [] = new BigInteger[5]; bigValue[0] = new BigInteger("6464764"); bigValue[1] = new BigInteger("212112221122"); bigValue[2] = new BigInteger("76475"); bigValue[3] = new BigInteger("94874747"); bigValue[4] = new BigInteger("2635474"); for(int i = 0; i< bigValue.length; i++) ... Read More
74 Views
A double array for the buffer can be obtained using the method array() in the class java.nio.DoubleBuffer. If the returned array is modified, then the contents of the buffer are also similarly modified and vice versa. If the buffer 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.*; public class Demo { public static void main(String[] args) { int n = 5; try { DoubleBuffer buffer = DoubleBuffer.allocate(n); buffer.put(4.5D); buffer.put(1.2D); ... Read More
83 Views
The equality of two buffers can be checked using the method equals() in the class java.nio.DoubleBuffer. Two buffers are equal if they have the same type of elements, the same number of elements and the same sequence of elements. The method equals() returns true if the buffers are equal and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { DoubleBuffer buffer1 = DoubleBuffer.allocate(n); ... Read More
76 Views
A new DoubleBuffer with the content as a shared subsequence of the original DoubleBuffer can be created using the method slice() in the class java.nio.DoubleBuffer. This method returns the new DoubleBuffer that is read-only if the original buffer is read-only and direct if the original buffer is direct.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { DoubleBuffer buffer1 = DoubleBuffer.allocate(n); buffer1.put(4.5D); ... Read More
90 Views
A buffer can be compared with another buffer using the method compareTo() in the class java.nio.DoubleBuffer. This method returns a negative integer if the buffer is less than the given buffer, zero if the buffer is equal to the given buffer and a positive integer if the buffer is greater than the given buffer.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { DoubleBuffer buffer1 = DoubleBuffer.allocate(n); ... Read More
56 Views
A read-only double buffer can be created using the contents of a buffer with the method asReadOnlyBuffer() in the class java.nio.DoubleBuffer. The new buffer cannot have any modifications as it is a read-only buffer. However, the capacity, positions, limits etc. of the new buffer are the same as the previous buffer.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { DoubleBuffer buffer = DoubleBuffer.allocate(5); buffer.put(4.5D); ... Read More
74 Views
The buffer can be compacted using the compact() method in the class java.nio.DoubleBuffer. This method does not require a parameter and it returns the new compacted DoubleBuffer with the same content as the original buffer. If the buffer 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.*; public class Demo { public static void main(String[] args) { int n = 5; try { DoubleBuffer buffer = DoubleBuffer.allocate(n); buffer.put(1.2D); buffer.put(3.9D); ... Read More
58 Views
A new DoubleBuffer can be allocated using the method allocate() in the class java.nio.DoubleBuffer. This method requires a single parameter i.e. the capacity of the buffer. It returns the new DoubleBuffer that is allocated. If the capacity provided is negative, then the IllegalArgumentException is thrown.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { DoubleBuffer buffer = DoubleBuffer.allocate(5); buffer.put(4.5D); buffer.put(1.2D); ... Read More
74 Views
A duplicate buffer of a buffer can be created using the method duplicate() in the class java.nio.DoubleBuffer. This duplicate buffer is identical to the original buffer. The method duplicate() returns the duplicate buffer that was created.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { DoubleBuffer buffer1 = DoubleBuffer.allocate(5); buffer1.put(4.5D); buffer1.put(1.2D); buffer1.put(3.9D); buffer1.put(7.5D); ... Read More
65 Views
The required value can be written at the current position of the buffer and then the current position is incremented using the method put() in the class java.nio.DoubleBuffer. This method requires a single parameter i.e. the value to be written in the buffer and it returns the buffer in which the value is inserted.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { DoubleBuffer buffer = DoubleBuffer.allocate(5); ... Read More