/* * Strings.java * * This is a simple program that will be used to demonstrate * Strings. * * @author Brad Dennis * Created: 09/11/2016 * Modified: -- */ public class Strings { public static void main(String[] args) { //Part 1. // 1. Answer the first Part 1 question. // 2. Run this program. // 3. Answer the second Part 1 question. System.out.println("Hello World"); //Part 2. // 1. Comment the previous block using single line comment syntax. // 2. Uncomment the block below. // 3. Answer the first Part 2 question. // 4. Run this program. // 5. Answer the second Part 2 question. /* String helloWorld = "Hello World"; System.out.println(helloWorld); */ //Part 3. // 1. Comment the previous block using single line comment syntax. // 2. Uncomment the block below. // 3. Answer the first Part 3 question. // 4. Run this program. // 5. Answer the second Part 3 question. /* String helloWorld1 = "Hello World"; String helloWorld2 = helloWorld1; System.out.println(helloWorld2); */ //Part 4. // 1. Comment the previous block using single line comment syntax. // 2. Uncomment the block below. // 3. Answer the first Part 2 question. // 4. Run this program. // 5. Answer the second Part 2 question. /* String helloWorld1 = "Hello World"; String helloWorld2 = helloWorld1; helloWorld1 = "Bonjour le monde"; System.out.println(helloWorld2); */ //Part 5. // 1. Go here: https://docs.oracle.com/javase/8/docs/api/java/lang/String.html // 2. Answer the first Part 5 question. // 3. Answer the second Part 5 question. //Part 6. // 1. Comment the previous block using single line comment syntax. // 2. Uncomment the block below. // 3. Read about this substring command: https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#substring-int-int- // 4. Answer the first Part 6 question. // 5. Run this program. // 6. Answer the second Part 6 question. /* String helloWorld = "Hello World"; System.out.println(helloWorld.substring(0,5)); */ //Part 7. // 1. Comment the previous block using single line comment syntax. // 2. Uncomment the block below. // 3. Read about this substring command: https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#substring-int- // 4. Answer the first Part 7 question. // 5. Run this program. // 6. Answer the second Part 7 question. /* String helloWorld = "Hello World"; System.out.println(helloWorld.substring(6)); */ //Part 8. // 1. Comment the previous block using single line comment syntax. // 2. Uncomment the block below. // 3. Read about this substring command: https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#charAt-int- // 4. Answer the first Part 8 question. // 5. Run this program. // 6. Answer the second Part 8 question. /* String helloWorld = "Hello World"; System.out.println(helloWorld.charAt(4)); */ //Part 9. // 1. Comment the previous block using single line comment syntax. // 2. Uncomment the block below. // 3. Read about this substring command: https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#length-- // 4. Answer the first Part 9 question. // 5. Run this program. // 6. Answer the second Part 9 question. // 7. Answer the third, fourth, and fifth Part 8 questions. /* String helloWorld = "Hello World"; System.out.println(helloWorld.length()); */ //Part 10. // 1. Comment the previous block using single line comment syntax. // 3. Read about this indexOf command: https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#indexOf-java.lang.String- // 4. Write a program that will: // a. Declare and initialize a variable named myHelloWorld with the string literal "My Hello World". // b. Print out to the console the index of the letter H. // 6. Answer the Part 10 question. } }