Guest User

Untitled

a guest
Jul 12th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. import java.lang.StringBuilder;
  2.  
  3. public class Program {
  4. public static void main(String[] args) {
  5.  
  6. int idSolicitud = 300;
  7. double numCifra = 3.14;
  8. char usuarioBD = 'A';
  9.  
  10. // Creas un nuevo StringBuilder.
  11. StringBuilder builder = new StringBuilder();
  12.  
  13. // Agregas los String o Variables al builder con append
  14. builder.append("Solicitud [idSolicitud="); //String
  15. builder.append(idSolicitud); // Var
  16. builder.append(", numCifra=");
  17. builder.append(numCifra);
  18. builder.append(", usuarioBD=");
  19. builder.append(usuarioBD);
  20. builder.append("]");
  21.  
  22. // Conviertes a string
  23. String result = builder.toString();
  24.  
  25. // Print result.
  26. System.out.println(result);
  27. }
  28. }
  29.  
  30. // Inserta un substring en la posición 2.
  31. builder.insert(2, "xyz");
  32.  
  33. // Intenta encontrar la posición del substring.
  34. int result = builder.indexOf("bc");
  35.  
  36. // Borra los characteres desde el index 2 hasta el index 5.
  37. builder.delete(2, 5);
Add Comment
Please, Sign In to add comment