“Stringbuffer en Java” Código de respuesta

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

Respuestas similares a “Stringbuffer en Java”

Preguntas similares a “Stringbuffer en Java”

Más respuestas relacionadas con “Stringbuffer en Java” en Java

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código