---
title: "How to write an array format using java"  
description: "How to write an array format using java"  
author: "Madam Walker"  
published: 2013-10-14  
updated: 2013-10-14  
canonical: https://www.mindstick.com/forum/1656/how-to-write-an-array-format-using-java  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# How to write an array format using java

I have declared this [variable](https://www.mindstick.com/articles/1807/objective-c-data-types-variables-object-creation) in [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp)(something), here is the code

```
long test[];
int year;
```

and I have declared a [method](https://www.mindstick.com/forum/166/webservice-method)(something) in class(something). here is the code

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

\

and then in the main class,i tried to set the [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) of jumlah[] and tahun, here is the code

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

\

the [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing) was

```
required: long[]
found: String
```

\

So, my [question](https://www.mindstick.com/blog/23175/how-to-solve-neet-question-paper-in-less-time) is, what is the [right](https://www.mindstick.com/articles/12766/check-whether-you-are-doing-digital-transformation-right-or-not) syntax do set the [array values](https://www.mindstick.com/forum/159317/merge-json-array-values-across-multiple-rows-in-mysql) of jumlah[] or replacing "the error"?

I've tried {123,321},[123,321],[{123,321}] and it doesn't work.

## Replies

### Reply by Anonymous User

something accepts an [array](https://www.mindstick.com/articles/335/jagged-array-in-c-sharp-dot-net) 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);
```


---

Original Source: https://www.mindstick.com/forum/1656/how-to-write-an-array-format-using-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
