ShortBuffer toString() method in Java with Examples
The toString() method in java.nio.ShortBuffer is used to return a string summarizing the state of this buffer.
Syntax:
public String toString()
Return Value:The method returns a summary string.
Below are the examples to illustrate the toString() method:
Program 1:
// Java program to demonstrate // toString() method import java.nio.*; import java.util.*; public class GFG { public static void main(String[] args) { // creating Shortbuffere ShortBuffer bb = ShortBuffer.allocate(100); bb.put((short)20); bb.put((short)30); // using toString method System.out.println(bb.toString()); } } |
chevron_right
filter_none
Output:
java.nio.HeapShortBuffer[pos=2 lim=100 cap=100]
Program 2:
// Java program to demonstrate // toString() method import java.nio.*; import java.util.*; public class GFG { public static void main(String[] args) { // creating Shortbuffere ShortBuffer bb = ShortBuffer.allocate(300); bb.put((short)20); bb.put((short)30); bb.rewind(); // using toString method System.out.println(bb.toString()); } } |
chevron_right
filter_none
Output:
java.nio.HeapShortBuffer[pos=0 lim=300 cap=300]
Recommended Posts:
- ShortBuffer compact() method in Java With Examples
- ShortBuffer hasArray() method in Java with Examples
- ShortBuffer reset() method in Java with Examples
- ShortBuffer arrayOffset() method in Java With Examples
- ShortBuffer rewind() method in Java with Examples
- ShortBuffer duplicate() method in Java With Examples
- ShortBuffer array() Method in Java with Examples
- ShortBuffer equals() method in Java with Examples
- ShortBuffer compareTo method in Java with Examples
- ShortBuffer asReadOnlyBuffer() method in Java with Examples
- ShortBuffer limit() method in Java with Examples
- ShortBuffer mark() method in Java with Examples
- ShortBuffer slice() method in Java with Examples
- ShortBuffer order() Method in Java with Examples
- ShortBuffer hashCode() Method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



