StringMethods

StringMethods - sentence.endsWith"hot"/Line 11 System.out.println"Line 12 sentence ends with str1" sentence.endsWith(str1/Line 12

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//String methods - startsWith, endsWith, toLowerCase, // and regionMatches / public class StringMethods { public static void main (String[] args) { String sentence = "It is cloudy and warm."; //Line 1 String str1 = "warm."; //Line 2 String str2 = "Programming with Java"; //Line 3 String str3 = "cloudy"; //Line 4 String str4 = "Learning Java Programming is exciting"; //Line 5 System.out.println("Line 6: sentence = \"" + sentence + "\""); //Line 6 System.out.println("Line 7: str1 = \"" + str1 + "\""); //Line 7 System.out.println("Line 8: sentence starts with It?: " + sentence.startsWith("It")); //Line 8 System.out.println("Line 9: sentence starts with str1?: " + sentence.startsWith(str1)); //Line 9 System.out.println("Line 10: sentence in lowercase = \"" + sentence.toLowerCase() + "\""); //Line 10 System.out.println("Line 11: sentence ends with hot?: "
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: + sentence.endsWith("hot")); //Line 11 System.out.println("Line 12: sentence ends with str1?: " + sentence.endsWith(str1)); //Line 12 System.out.println("Line 13: str2 = \"" + str2 + "\""); //Line 13 System.out.println("Line 14: str2 in lowercase: " + str2.toLowerCase()); //Line 14 System.out.println("Line 15: str3 = \"" + str3 + "\""); //Line 15 System.out.println("Line 16: " + "sentence.regionMatches(6,str3,0,6)?: " + sentence.regionMatches(6,str3,0,6)); //Line 16 System.out.println("Line 17: " + "sentence.regionMatches(true,6,\"Cloudy\",0,6)?: " + sentence.regionMatches(true,6,"Cloudy",0,6)); //Line 17 System.out.println("Line 18: str4 = \"" + str4 + "\""); //Line 18 System.out.println("Line 19: " + "str4.regionMatches(9,str2,17,4): " + str4.regionMatches(9,str2,17,4)); //Line 19 } }...
View Full Document

This note was uploaded on 06/17/2011 for the course COMP 2301 taught by Professor Staff during the Spring '10 term at Kennesaw.

Ask a homework question - tutors are online