1 / 5

Strings

Strings. Modified 02/17/2016 by Laurie Murphy. Strings. name. String name;. ?. name = “ Jenn Lawrence ” ;. “ Jennifer Lawrence ”. “ Jenn Lawrence ”. name = “ Jennifer Lawrence ” ;. “ Jennifer Lawrence ”. Strings are immutable. String methods. String name = “ Katniss ” ;. name.

berning
Download Presentation

Strings

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Strings Modified 02/17/2016 by Laurie Murphy

  2. Strings name String name; ? name = “Jenn Lawrence”; “Jennifer Lawrence” “Jenn Lawrence” name = “Jennifer Lawrence”; “Jennifer Lawrence” Strings are immutable

  3. String methods String name = “Katniss”; name System.out.println(name.toUpperCase()); System.out.println(name.toLowerCase()); “Katniss” System.out.println(“length = “ + name.length()); 0123456 System.out.println(“first = “ + name.charAt(0)); System.out.println(“last = “ + name.charAt(6)); System.out.println(“last = “ + name.charAt(7)); KATNISS katniss length = 7 first = K last = s Exception in thread “main” java.lang.StringIndexOutOfBoundsException

  4. String Practice – What’s the output? String greeting = “Hello World!”; System.out.println(greeting.toUpperCase()); System.out.println(greeting.length()); System.out.println(greeting.charAt(9)); System.out.println(greeting.charAt(greeting.length());

  5. Pair Practice Download and complete StringPractice.java

More Related