I'm trying to make an array of integers in java but it won't work for some reason...
I've done the following
int[][] vLines = new int[2][2];
I get issues from Eclipse when I try to initialize my array elements,
vLines[0][0] = (int)(1*.33);
vLines[0][1] = (int)(1*.33);
vLines[1][0] = (int)(1*.33);
vLines[1][1] = (int)(1*.33);
When I try to store values in my array elements eclipse says "Syntax error, insert '}' to complete block" in the last line of my array init's..
I know there is nothing wrong with my brace balancing in my program...
I thought it might be the cast so I removed '(int)', still doesn't work...
i tried initializing my elements to some integer (e.x. 1), still doesn't work...
I've tried initializing one element, still doesn't work...
I tried splitting my int array declaration to 2 lines and then continuing like this but it still didn't work...
int[][] vLines;
vLines = new int[2][2];
but I still get an error in regards to balancing...
I also tried just copying and pasting java 2D arrays examples from online tutorials and they wont work in eclipse, i've closed and started eclipse and cleaned proj.. still notta
What am I missing? I need my array elements to be dynamically initialized but i can't get my simple 2d array to hold anything...
Here is my whole code file...
import javax.swing.*;
import java.awt.*;
public class ColoredGrid extends JPanel {
final int ROWS = 2;
final int COLS = 2;
int vLines[][] = new int[ROWS][COLS];
vLines[0][0] = (int)(1*.33);
vLines[0][1] = (int)(1*.33);
vLines[1][0] = (int)(1*.33);
vLines[1][1] = (int)(1*.33);
public ColoredGrid() {
}
protected void paintComponent(Graphics g){
super.paintComponent(g);
}
}
(int)(1*.33)is just0, which is what the elements would be initialized to anyway.