What's new

Closed Error int[] array initialized in private method

Status
Not open for further replies.

Princess Serrano

Eternal Poster
Joined
Apr 2, 2016
Posts
429
Reaction
285
Points
285
Bakit ganooonnnnnn??

public class Main {
private int[] a, b;

private void setup() {
this.a = {3,5,3}; // error
this.b = {4,3,3,2,4,54}; // error
}
}
 
I dont know if this is Java or C# but in C# it should be something like this:

Code:
private void setup()
{
    int[] a = new int[] {3,5,3};
    int[] b = new int[] {4,3,3,2,4,54};
}

In Java:

Code:
int a[]={3,5,3};
 
Status
Not open for further replies.

Similar threads

Back
Top