Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Eclipse 2D array of int won't work
    primarykey
    data
    text
    <p>I'm trying to make an array of integers in java but it won't work for some reason...</p> <p>I've done the following</p> <pre><code>int[][] vLines = new int[2][2]; </code></pre> <p>I get issues from Eclipse when I try to initialize my array elements,</p> <pre><code> vLines[0][0] = (int)(1*.33); vLines[0][1] = (int)(1*.33); vLines[1][0] = (int)(1*.33); vLines[1][1] = (int)(1*.33); </code></pre> <p>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..</p> <p>I know there is nothing wrong with my brace balancing in my program...</p> <p>I thought it might be the cast so I removed '(int)', still doesn't work...</p> <p>i tried initializing my elements to some integer (e.x. 1), still doesn't work...</p> <p>I've tried initializing one element, still doesn't work...</p> <p>I tried splitting my int array declaration to 2 lines and then continuing like this but it still didn't work...</p> <pre><code>int[][] vLines; vLines = new int[2][2]; </code></pre> <p>but I still get an error in regards to balancing... </p> <p>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 </p> <p>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...</p> <p>Here is my whole code file...</p> <pre><code>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); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload