Class StringExamples


  • public class StringExamples
    extends java.lang.Object
    This code illustrates the use of String methods
    Version:
    1.0
    Author:
    Brad Richards
    • Constructor Summary

      Constructors 
      Constructor Description
      StringExamples()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String firstName​(java.lang.String fullName)
      Takes a string like "Brad Richards" and returns just the first name, "Brad".
      java.lang.String middleName​(java.lang.String fullName)
      I want to take a name like "Bradley Eric Richards" and just chop out and return the "Eric" part.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StringExamples

        public StringExamples()
    • Method Detail

      • firstName

        public java.lang.String firstName​(java.lang.String fullName)
        Takes a string like "Brad Richards" and returns just the first name, "Brad". It looks for the first space and returns a string containing everything that comes before it. We assume that there really is a space in the input name.
        Parameters:
        fullName - A string representing the user's full name.
        Returns:
        Just the user's first name.
      • middleName

        public java.lang.String middleName​(java.lang.String fullName)
        I want to take a name like "Bradley Eric Richards" and just chop out and return the "Eric" part.
        Parameters:
        fullName - A name that includes a middle name
        Returns:
        Just the middle name