Results 1 to 5 of 5
  1. #1
    jmscarlet9 is offline Member
    Join Date
    Feb 2012
    Posts
    57
    Rep Power
    0

    Default getInitials Method

    Hey everyone,
    Time for a new set of problems. I'm working on the first and thought I was pretty close. However, when I added in some test coding, I'm getting "cannot find symbol" errors on that part of the code. I want to make sure my method is working correctly and I know it's something stupid that I'm staring right at. Can someone help me figure out why I'm getting the errors? The instructions for the assignment are commented at the beginning of the code.

    Here is my code:

    Java Code:
    public class InitialsTest
    {
       /**
          Gets the initials of this name
          @params first, middle, and last names
          @return a string consisting of the first character of the first, middle,
          and last name
       */
       public static String getInitials(String one, String two, String three)
       {
    
          // your work here
    		String initials = one.substring(0, 1) + two.substring(0, 1) + three.substring(0, 1);
    		return initials;
    
       }
    	public static void main(String[] args)
    	{
    	System.out.println("Initials are: " + getInitials(John, Jacob, Smith));
    	}
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default Re: getInitials Method

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    jmscarlet9 is offline Member
    Join Date
    Feb 2012
    Posts
    57
    Rep Power
    0

    Default Re: getInitials Method

    WHOOSH...that's what that page says going right over my head. Anything more specific? (I'm only 6 weeks into this programming class)

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default Re: getInitials Method

    What does the first sentence after the heading "String Literals" say? Surely that's not over anyone's head.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    jmscarlet9 is offline Member
    Join Date
    Feb 2012
    Posts
    57
    Rep Power
    0

    Default Re: getInitials Method

    Got it. I was making it harder than it needed to be. Thank you!!! :)

Similar Threads

  1. Replies: 1
    Last Post: 10-27-2011, 07:16 AM
  2. Replies: 1
    Last Post: 10-17-2011, 01:00 AM
  3. Declaring a method inside a method: Runnable?
    By africanhacker in forum New To Java
    Replies: 8
    Last Post: 03-23-2011, 04:30 AM
  4. Replies: 2
    Last Post: 03-26-2010, 05:12 PM
  5. cannot call private method from static method
    By jon80 in forum New To Java
    Replies: 3
    Last Post: 05-07-2008, 08:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •