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

  • Home
  • SEARCH
  • 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 7961013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:54:47+00:00 2026-06-04T04:54:47+00:00

I have this snippet of java code. I am a noob in java.. Error

  • 0

I have this snippet of java code. I am a noob in java..

Error :

<identifier> expected
cfg = new Config;

Code:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.io.*; 

import java.util.*;
import java.util.Properties;

public class Config 
{

   Properties configFile;
  public Config()
{
configFile = new java.util.Properties();
try {           
  configFile.load(this.getClass().getClassLoader().getResourceAsStream("config"));          
}catch(Exception eta){
    eta.printStackTrace();
}
  }

  public String getProperty(String key)
  {
 String value = this.configFile.getProperty(key);       
    return value;
  }

}



public class ClosureBuilder {

cfg = new Config();

private static String JDBC = cfg.getProperty("JDBC");
private static String URL = cfg.getProperty("URL");
private static String DIMENSION_TABLE = cfg.getProperty("DIMENSION_TABLE");
private static String CLOSURE_TABLE = cfg.getProperty("CLOSURE_TABLE");
private static String KEY = cfg.getProperty("KEY");
private static String PARENT_KEY = cfg.getProperty("PARENT_KEY");

private static Object TOP_LEVEL_PARENT_KEY = '0';


private Object topLevel = null;

private Set<Object> processedNodes;

private PreparedStatement aPst;
public static void main(String[] args) throws Exception {

----------- More code --------
  • 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-06-04T04:54:48+00:00Added an answer on June 4, 2026 at 4:54 am

    Yes, this is the problem:

    public class ClosureBuilder {
        cfg = new Config();
        ...
    }
    

    At the top level of a class, you can only have:

    • Instance initializer blocks ({ ... })
    • Static initializer blocks (static { ... })
    • Variable declarations
    • Constructor declarations
    • Method declarations
    • Nested type declarations
    • Finalizer declarations

    This is none of these. If you meant to declare a variable, you should have done so:

    private Config cfg = new Config();
    

    If that’s not what you intended to do, you should explain your intention.

    EDIT: Once you’ve fixed that, this compiler error seems pretty clear:

    class Config is public, should be declared in a file named Config.java

    There are two potential fixes for this:

    • Make Config non-public
    • Move it to a file called Config.java

    Either should fix that error (potentially revealing more).

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

Sidebar

Related Questions

I have this code snippet import java.util.ArrayList; import java.util.List; public class AssertTest { public
I have this JSP code snippet: <%@ taglib uri=http://java.sun.com/jsp/jstl/core prefix=c%> <c:choose> <c:when test=${var1.properties[\Item Type\]
I have this code snippet: DateFormat formatter1; formatter1 = new SimpleDateFormat(mm/DD/yyyy); System.out.println((Date)formatter1.parse(08/16/2011)); When I
I have the following snippet of java code: final Class<?> junitCoreClass = AccessController.doPrivileged( new
in my Java code I have this snippet: String str = \\u9601; But I
// Refer: http://en.wikipedia.org/wiki/Decimal I have a snippet like this in my java source code,
On Mac OS X 10.5 with Java 1.5, I have this code snippet. public
I have this snippet of code private Templates retrieveFromCache(String name) { TemplatesWrapper t =
I have this snippet of code below. I want to pass the value of
I have this code snippet: <div id=div1> </div> <div id=div2> <h3>This is the content</h3>

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.