need help

A

ankit gupta

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();
}
}
 
R

RedGrittyBrick

ankit said:
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();
}
}
 
J

Jeff Higgins

ankit said:
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();
}
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top