Results 1 to 6 of 6
  1. #1
    chewdoggie is offline Member
    Join Date
    Oct 2013
    Posts
    6
    Rep Power
    0

    Default Question about syntax I'm viewing

    Hello All,

    I've been assigned the task of figuring out how an existing Java Application runs and what it does.

    I'm a C# developer trying to learn Java, but not being given much time to do it. In the source code, I see a call to a method (function) that looks like this:

    String temp = readUntil("Master:", "[c");

    This is easy to figure out, the 'readUntil' function is being called, passing two String parameters and returning a string value. However, the actual function definition looks like this:

    private String readUntil(String... strs) throws IOException {
    ...code
    }

    What is the "String... strs" ? In C#, we call this a "method's signature". It doesn't look like the signature matches the call.

    Help.

    Chew

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,848
    Rep Power
    5

    Default Re: Question about syntax I'm viewing

    Its a variable argument list.

    You're not going to learn the language by looking at code only; at least take the time to read through a book or the Oracle Java tutorial. Shouldn't take you more than a day to skim the most important parts from it.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,433
    Blog Entries
    7
    Rep Power
    20

    Default Re: Question about syntax I'm viewing

    String ... strs means zero or more Strings; it resembles the varargs construct in C (and C++) strs.length gives you the number of arguments passed to the method and the individual arguments are strs[0], strs[1] etc; aamof strs is a String array (String[]).

    kind regards,

    Jos

    edit: darn, who's the slowest old sod again?
    Last edited by JosAH; 10-30-2013 at 04:36 PM.
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: Question about syntax I'm viewing

    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,433
    Blog Entries
    7
    Rep Power
    20

    Default Re: Question about syntax I'm viewing

    Quote Originally Posted by PhHein View Post
    Of course, I didn't expect anything else; while I was beaten by a few micro seconds (and my reply was beautifully composed; it was sheer poetry), your one line reply came eons later ;-)

    kindest regards,

    Jos (<-- poet)
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    chewdoggie is offline Member
    Join Date
    Oct 2013
    Posts
    6
    Rep Power
    0

    Default Re: Question about syntax I'm viewing

    Thanx all. I love the responses in these forums.

    Chew

Similar Threads

  1. For loop syntax question
    By salad90 in forum New To Java
    Replies: 20
    Last Post: 12-07-2010, 06:28 AM
  2. Syntax question
    By rockeater in forum New To Java
    Replies: 3
    Last Post: 08-31-2010, 11:52 PM
  3. A question about syntax.
    By mr_o in forum New To Java
    Replies: 2
    Last Post: 09-19-2009, 08:30 PM
  4. Help with viewing Applet
    By adamsives in forum New To Java
    Replies: 1
    Last Post: 04-09-2009, 07:28 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
  •