“Stringbuffer en java” Réponses codées

Stringbuffer en 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
    }
}
Wissam

Stringbuffer en java


String third = first + second;

Modern Mouse

Réponses similaires à “Stringbuffer en java”

Questions similaires à “Stringbuffer en java”

Plus de réponses similaires à “Stringbuffer en java” dans Java

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code