Home > DeveloperSection > Forums > How to write an array format using java
Madam Walker
Madam Walker

Total Post:22

Posted on    October-14-2013 3:32 AM

 Java Java 

 1 Reply(s)
 1169  View(s)
Rate this:

I have declared this variable in class(something), here is the code

long test[];
int year;

and I have declared a method(something) in class(something). here is the code

public void something(long check[],int year) {
    for(int i=0;i<=1;i++){

and then in the main class,i tried to set the value of jumlah[] and tahun, here is the code

something dood = new something();
dood.something("the error",2013);//error here

the error was

required: long[]
found: String

So, my question is, what is the right syntax do set the array values of jumlah[] or replacing "the error"?

I've tried {123,321},[123,321],[{123,321}] and it doesn't work.

Ida B Wells
Ida B Wells

Total Post:30

Posted on    October-14-2013 4:04 AM

something accepts an array of long as the first argument and an int as the second argument.
Your'e trying to pass to it a
 String and an int.

You should do something like that:

foo.something(new long[] { 1, 2, 3, 4}, 2014);

Don't want to miss updates? Please click the below button!

Follow MindStick