Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication1;
- /**
- *
- * @author hristijan.petrovs
- */
- public class JavaApplication1 {
- public static void main(String[] args) {
- String a = "Computer";
- System.out.println(a);
- System.out.println(a.toUpperCase());
- System.out.println(a.toLowerCase());
- System.out.println("The length of the word is: " + a.length());
- System.out.println("The letter at the first position is: " + a.charAt(0));
- System.out.println("The letter at the last position is: " + a.charAt(a.length()-1));
- System.out.println("The letter at the middle position is: " + a.charAt(a.length()/2));
- if (a.startsWith("Com")){
- System.out.println("The string starts with 'Com'");
- }
- else{
- System.out.println("The string doesn't start with 'Com'");
- }
- if (a.endsWith("ion")){
- System.out.println("The string ends with 'ion'");
- }
- else{
- System.out.println("The string doesn't end with 'ion'");
- }
- System.out.println(a.substring(0, 2));
- System.out.println(a.replace('e','o'));
- System.out.println(a.replaceFirst("Comp," "Calcula"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement