Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package javaapplication1;
  7.  
  8. /**
  9. *
  10. * @author hristijan.petrovs
  11. */
  12. public class JavaApplication1 {
  13.  
  14.  
  15. public static void main(String[] args) {
  16.  
  17. String a = "Computer";
  18.  
  19. System.out.println(a);
  20. System.out.println(a.toUpperCase());
  21. System.out.println(a.toLowerCase());
  22. System.out.println("The length of the word is: " + a.length());
  23. System.out.println("The letter at the first position is: " + a.charAt(0));
  24. System.out.println("The letter at the last position is: " + a.charAt(a.length()-1));
  25. System.out.println("The letter at the middle position is: " + a.charAt(a.length()/2));
  26.  
  27. if (a.startsWith("Com")){
  28. System.out.println("The string starts with 'Com'");
  29. }
  30. else{
  31. System.out.println("The string doesn't start with 'Com'");
  32. }
  33.  
  34. if (a.endsWith("ion")){
  35. System.out.println("The string ends with 'ion'");
  36. }
  37. else{
  38. System.out.println("The string doesn't end with 'ion'");
  39. }
  40.  
  41. System.out.println(a.substring(0, 2));
  42.  
  43.  
  44.  
  45. System.out.println(a.replace('e','o'));
  46.  
  47. System.out.println(a.replaceFirst("Comp," "Calcula"));
  48.  
  49.  
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement