Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package lesson1;
- /**
- *
- * @author pclab
- */
- public class stringmethods {
- public static void main(String[] args)
- {
- String str1="Burger", str2="King";
- String str3="BURGER", str4="burger";
- System.out.println("Length of str1:"+str1.length());
- System.out.println("Length of str2:"+str2.length());
- System.out.println("Substring method:"+str4.substring(2, 6));
- System.out.println("Substring method:"+str3.substring(3));
- System.out.println("to lower case:"+str3.toLowerCase());
- System.out.println("to upper case:"+str4.toUpperCase());
- System.out.println("Equals method:"+str3.equals(str4));
- System.out.println("Equals Ignorecase mehod:"+str3.equalsIgnoreCase(str4));
- System.out.println("Index of a:"+str4.indexOf('a'));
- System.out.println("Last index of a:"+str4.lastIndexOf('a'));
- String str5 = str1 + " "+str2;
- System.out.println(str5);
- System.out.println("String 5 Length: "+str5.length());
- System.out.println(str3.compareTo(str4);
- System.out.println(str4.compareTo(str3);
- System.out.println(str3.compareTo(str3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement