Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6762193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:17:18+00:00 2026-05-26T14:17:18+00:00

I’ve got two compile errors in one of my classes and I don’t understand

  • 0

I’ve got two compile errors in one of my classes and I don’t understand why they’re there.

The top error is saying there needs to be another semi-colon and the bottom one says it needs another closing brace.

The bottom error disappears if i put in another curly brace but the top one doesn’t. Any ideas?

(This is probably a case of me being blind/stupid so i apologise in advance 🙂

package com.pathfinding;

import java.util.ArrayList;


public class EdgeNodeFactory
{
static boolean[][] edgeMatrix = new boolean[100][100];
for (int i = 0; i < 100; i++)
{
    for (int j = 0; j < 100; j++)
    {
        edgeMatrix[i][j] = false;
    }
}

static ArrayList<Node> nodes = new ArrayList<Node>();
static ArrayList<Edge> edges = new ArrayList<Edge>();

static int edgeCount = 0;
static int nodeCount = -1;
}

errors regarding curly braces

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:17:18+00:00Added an answer on May 26, 2026 at 2:17 pm

    You’ve tried to put code (the for loop) directly in your class – it’s not in a constructor, a method, or a static/instance initializer. That’s not valid. When do you want that code to be executed?

    I suspect your code should really look like this:

    public class EdgeNodeFactory
    {
        private boolean[][] edgeMatrix = new boolean[100][100];
        private int edgeCount = 0;
        private int nodeCount = -1;
        private List<Node> nodes = new ArrayList<Node>();
        private List<Node> edges = new ArrayList<Edge>();
    
        public EdgeNodeFactory()
        {
            // You *could* put your for loop here... but the array
            // elements will all be false anyway, as that's the default...
    
            // If you don't need any code in this constructor, and you
            // don't declare any other constructors, you can remove it
            // entirely - the compiler will create it by default.
        }
    
        // Other methods here
    }
    

    Note how I’ve made all the fields private and non-static… you should almost certainly be creating an instance of EdgeNodeFactory rather than using static fields, and you should almost always make fields private.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm making a simple page using Google Maps API 3. My first. One marker
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.