Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

stringbuffer in java

// Java Program showcasing some of StringBuffer class capabilities
import java.io.*;
 
class StringBufferDemo {
     public static void main(String[] args) {
        // Creating StringBuffer object
        StringBuffer s = new StringBuffer("Dummy value");
        // Getting the length of object
        int length = s.length();
 
        // Getting the capacity of object
        int capacity = s.capacity();
 
        // Printing the length and capacity of
        System.out.println("Length of string buffer = "
                           + length); // 11
        System.out.println(
            "Capacity of string buffer = " + capacity); // 27
        
        // append method
        s.append(" appended");
        System.out.println(s); // Dummy value appended
        
        // insert method
       	s.insert(s.length(), " for illustration."); 
        System.out.println(s); // Dummy value appended for illustration.
         
        // delete method
        s.delete(0, 6);
        System.out.println(s); // value appended for illustration.
        
        // deleteCharAt method
        s.deleteCharAt(0);
        System.out.println(s); // alue appended for illustration.
        
        // reverse method
        s.reverse();
        System.out.println(s); // .noitartsulli rof dedneppa eula
    }
}
Comment

stringbuffer in java


String third = first + second;

Comment

PREVIOUS NEXT
Code Example
Java :: java sort a Map by keys reverse descending order 
Java :: java mail use tls 1.2 
Java :: android java shared preferences remove key 
Java :: how to reverse a number in java 
Java :: Java Method Return Type 
Java :: reverseString 
Java :: how to make priority queue of pairs in java 
Java :: how to get 2 decimal places in java 
Java :: regex pattern for valid logins 
Java :: java program to find the power of a number 
Java :: character types java 
Java :: add Duration to date in Kotlin 
Java :: java String revers 
Java :: send message bukkit 
Java :: java instanceof 
Java :: how to convert kilometers to miles in java 
Java :: There is no client authentication. Try adding an appropriate authentication filter 
Java :: checkc if string is double java 
Java :: java variable declaration 
Java :: java sort arraylist of arraylist 
Java :: button getsource 
Java :: java how to create an array with existing objects 
Java :: list.of java 
Java :: Java User Input (Scanner) 
Java :: comparacion de strings java 
Java :: latest android sdk version 
Java :: why enable multidex android 
Java :: get imei android programmatically android 10 
Java :: deserialize list jackson 
Java :: java equal string 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =