Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Java{
- public static void main(String args[]){
- String business = "Zach Dyer Design";
- //Returns the index of the first "D"
- System.out.println(business.indexOf("D"));
- //Starts to search the string from index 7 and returns 10
- System.out.println(business.indexOf("D",7));
- String first = "Zach ";
- String last = "Dyer";
- //Concatenate strings
- System.out.println(first + last);
- //Concatenate strings
- System.out.println(first.concat(last));
- //Replace Zach with Kris and concatenate first and last name
- System.out.println(first.replace("Zach", "Kris") + last);
- String boom = "boom";
- //Print string to uppercase
- System.out.println(boom.toUpperCase());
- String loud = "I AM SPEAKING LOUD";
- //Prints string to lowercase
- System.out.println(loud.toLowerCase());
- String trimString = " I need some trimming up ";
- //Cleans up the blank spaces before and after the string.
- System.out.println("<" + trimString.trim() + ">");
- //Here some weird stuff
- System.out.println(trimString.getBytes());
- //Some more
- System.out.println(trimString.hashCode());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement