More on Strings - PowerPoint PPT Presentation

About This Presentation
Title:

More on Strings

Description:

More on Strings. Yes, dudes! Strings... If you go check the docs... C:j2sdk1.4.2_05docsapi ... a = new String('Bishop's College School'); b = new String ... – PowerPoint PPT presentation

Number of Views:14
Avg rating:3.0/5.0
Slides: 9
Provided by: angel101
Category:
Tags: dudes | more | strings

less

Transcript and Presenter's Notes

Title: More on Strings


1
More on Strings
  • Yes, dudes!

2
Strings
  • If you go check the docs C\j2sdk1.4.2_05\docs\ap
    i
  • Double click on the index.html
  • Find the class String
  • Browse through the methods

3
Try this
4
Try this
  • public class MoreStrings
  • public static void main(String args)
  • String a, b, c
  • int i
  • a new String("Bishop's College School")
  • b new String("BishopsCollegeSchool")
  • System.out.println(a)
  • System.out.println(a.length())
  • for (i0 ilta.length()i)
  • System.out.println(a.charAt(i))

What does this do?
5

Surprised???
6
Assignment 6
  • Use Strings to do all this in one single java
    file.
  • Create a string that contains Bishops College
    School. Use the method replace to replace all
    the s by z and display the result.
  • Create a string that contains Bishops College
    School. Use the method replaceAll to replace
    the word Bishop by King.
  • Use the method toUpperCase to convert the string
    Bishops College School.
  • Use the method indexOf to find the index of the
    substring College

7
Assignment 6
  1. Create a string x that contains Hello and a
    string y that contains Hello also. Use the
    method compareTo in a if statement and show a
    message if they are the same
  2. Write a program that will take the String
    Bishops College School and will revert it

8
Like this
Write a Comment
User Comments (0)
About PowerShow.com