Results 1 to 6 of 6

Thread: String s = ...;

  1. #1
    Pojahn_M's Avatar
    Pojahn_M is offline Senior Member
    Join Date
    Mar 2011
    Location
    Sweden
    Posts
    197
    Rep Power
    4

    Default String s = ...;

    On some codes, I see something like this:

    Java Code:
    String s = ...;
    What does it mean?
    I know what 3 dots mean if it is on a method parameter, but not in this case.
    I would search for it on google, but I dont even know what to search for.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,259
    Rep Power
    25

    Default Re: String s = ...;

    Does that statement compile?
    It looks like an open example where the user is to change the ... to a valid value.

  3. #3
    vivekanand30 is offline *****
    Join Date
    Sep 2011
    Location
    Mumbai
    Posts
    8
    Rep Power
    0

    Default Re: String s = ...;

    I have never seen anything like this. I don't think it will compile(atleast till 1.6). If it compile with any of the java version please tell me. I would like to know..

  4. #4
    Alerhau's Avatar
    Alerhau is offline Senior Member
    Join Date
    Jun 2011
    Location
    Sweden
    Posts
    158
    Rep Power
    4

    Default Re: String s = ...;

    String s = ...; does'nt compile, I tried it out for you guys.
    It just say: Syntax error on token "...", invalid VariableInitializer in Eclipse.

    And when you run it, I get "Could not find the main class: *Your class*. Program will exit."
    Currently Developing a Game Called Loaie, You Can Download It From "The Loaie Website".

  5. #5
    vivekanand30 is offline *****
    Join Date
    Sep 2011
    Location
    Mumbai
    Posts
    8
    Rep Power
    0

    Default Re: String s = ...;

    It will never compile. I don't know where you get all these syntax. It doesn't have any existence as per my knowledge. Second thing why u r trying to run a programe which is not yet compiled. How could i add signature with my post could you please tell me?
    Last edited by vivekanand30; 09-04-2011 at 07:38 PM.

  6. #6
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default Re: String s = ...;

    As norm said, it's short hand. When I show snippets I use it often(especially when posting on my phone). For example I generally will type
    Java Code:
    List<String> list = ...;
    Rather than typing the extra words or suggesting what type of list to use, I leave just ... For you to replace. It works similarly for Strigs or any other class.

Similar Threads

  1. Replies: 11
    Last Post: 08-15-2011, 10:12 AM
  2. Replies: 12
    Last Post: 11-26-2010, 08:33 AM
  3. Replies: 1
    Last Post: 11-04-2010, 06:53 PM
  4. Replies: 5
    Last Post: 01-11-2009, 10:12 AM
  5. Replies: 0
    Last Post: 11-20-2007, 04:59 PM

Posting Permissions

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