need help

Discussion in 'Java' started by ankit gupta, Jul 28, 2008.

  1. ankit gupta

    ankit gupta Guest

    can any one teel me whts the problem in this code]
    class variablelength
    {
    static void vatest(int ... v)
    {
    System.out.print("number of args: "+ v.length+ " contents ");
    for (int x:v)
    System.out.println(x + " " );
    System.out.println();
    }
    public static void main(String args[])
    {
    vatest(10);
    vatest(1,2,3);
    vatest();
    }
    }
     
    ankit gupta, Jul 28, 2008
    #1
    1. Advertising

  2. ankit gupta wrote:
    > can any one teel me whts the problem in this code]


    I can tell you a few problems with it.

    However it might be more interesting for you if you told us in what way
    it doesn't do what you expect. Then we could focus on the specific
    problem you are interested in.


    > class variablelength


    According to Sun's Hava coding conventions, Class names should start
    with a capital letter. If a class name is comnposed of multiple words,
    each should start with a capital letter.

    class VariableLength

    > {
    > static void vatest(int ... v)
    > {
    > System.out.print("number of args: "+ v.length+ " contents ");
    > for (int x:v)
    > System.out.println(x + " " );


    Why add a space just before the newline?

    > System.out.println();


    This second line is indented as if it were contained within the for
    loop. But it isn't contained within the for loop.

    > }
    > public static void main(String args[])
    > {
    > vatest(10);
    > vatest(1,2,3);
    > vatest();
    > }
    > }




    --
    RGB
     
    RedGrittyBrick, Jul 28, 2008
    #2
    1. Advertising

  3. ankit gupta

    Jeff Higgins Guest

    ankit gupta wrote:
    > can any one teel me whts the problem in this code]
    > class variablelength
    > {
    > static void vatest(int ... v)
    > {
    > System.out.print("number of args: "+ v.length+ " contents ");
    > for (int x:v)


    > //System.out.println(x + " " );

    System.out.print(x + " ");

    > System.out.println();
    > }
    > public static void main(String args[])
    > {
    > vatest(10);
    > vatest(1,2,3);
    > vatest();
    > }
    > }
     
    Jeff Higgins, Jul 28, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TN Bella
    Replies:
    1
    Views:
    2,478
    Edward
    Jun 18, 2004
  2. Teep
    Replies:
    2
    Views:
    767
    Larry Marburger
    Jun 21, 2004
  3. John
    Replies:
    1
    Views:
    402
    John C. Bollinger
    Aug 19, 2004
  4. =?Utf-8?B?Q2hyaXM=?=

    Help Help. I really need some help with this

    =?Utf-8?B?Q2hyaXM=?=, Jan 31, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    569
    =?Utf-8?B?SmFzb24gVmVybWlsbGlvbg==?=
    Jan 31, 2007
  5. ElementX
    Replies:
    9
    Views:
    498
    RedGrittyBrick
    Oct 1, 2008
Loading...

Share This Page