Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Use a method to find out if any last name is "Doe".

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Use a method to find out if any last name is "Doe".

    I need to use a method to find out if any last name is "Doe". Use a loop statement to achieve this. Print out their full names.

    Here is the code that I have written. It works but I not sure that it addresses the question. Need help. Thanks in advance.

    class LastNameisDoe {
    public static void main(String args[]) {
    String s;

    for(int i=0; i < 1; i++) {
    s = "Doe";
    System.out.print(s);


    s = " John Doe";

    System.out.print(s + " ");
    }
    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,164
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Use a method to find out if any last name is "Doe".

    find out if any last name is "Doe"
    First you need to find the "last name". Given a String with a name, how do you find the "last" name?
    When you get the last name, Then compare it to "Doe"

  3. #3
    Junior Member
    Join Date
    Feb 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Use a method to find out if any last name is "Doe".

    Thanks Norm!

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,164
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Use a method to find out if any last name is "Doe".

    You're welcome

Similar Threads

  1. "Cannot find symbol" compilation error
    By collegejavastudent in forum What's Wrong With My Code?
    Replies: 7
    Last Post: December 12th, 2011, 05:07 PM
  2. Replies: 3
    Last Post: December 7th, 2011, 02:03 AM
  3. "Static method cannot hide instance method from implemented Interface"
    By Gthoma2 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 21st, 2011, 03:03 AM
  4. Replies: 1
    Last Post: March 15th, 2010, 10:03 PM
  5. "java.lang.NoSuchMethodError: main" and "fatal exception occured."
    By joachim89 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 10th, 2010, 08:35 AM