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 9232487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:19:34+00:00 2026-06-18T06:19:34+00:00

I was developing a program using NetBeans IDE and i got an error in

  • 0

I was developing a program using NetBeans IDE and i got an error in front of a line saying

illegal start of expression and below that written ‘;’ expected

I am new to Java and I am unable to fix this error when I was assigning a value to an array.

Below is a part of code where the error occured :


String[] colname;
   int j=0;
   while(rs.next()){
     for(int i=0;i<cols;i++){
       colname={dtm.getColumnName(i)};       //**<-- This is where the error occured**
                }
                    colName=colname;   //colName is also an array of String datatype.
                    Object[] value = {rs.getObject(colName[j])};
                    dtm.addRow(value);
                    j++;
                }

All apart the line

colname={dtm.getColumnName(i)};

Does not give any error. But the error occurs only in the above line.

I found myself unable to fix it. Can anyone help me to fix it?

  • 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-18T06:19:35+00:00Added an answer on June 18, 2026 at 6:19 am

    You have 2 ways of initializing an array:

    String[] colname= {dtm.getColumnName(i)};
    

    or

    colname= new String[] {dtm.getColumnName(i)};
    

    But you can’t mix them. In your case, you would use the latter because you don’t have the information to populate it yet on the line where you declare it.

    Note however that this is probably not going to do what you want as you will keep reassigning a new array at each loop. You could make your life easier by using an ArrayList instead:

    List<String> colName = new ArrayList<String> ();
    
    //in your loop
    colName.add(dtm.getColumnName(i));
    

    You can read more about arrays in this tutorial.

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

Sidebar

Related Questions

I'm developing a program that displays graphical windows using the windows API. Below is
I'm developing a program using Windows 7. There are WCF services (soap, rest) that
I am developing a computer vision program using OpenCV (IDE = devcpp). I am
I'm developing a program that I'm using a string( generatedCode ) that contains some
I am developing a Java program using Eclipse that should exit with different codes
I am developing a program by using JFrame and i want to realize that
I'm developing a program that load webpages using WebBrowser control in VB6. How do
I'm developing a program using App Inventor that will tweet stuff. I've assigned a
I have a Java program which required -Xmx1g memory. I am using Netbeans IDE
I have been developing a Java program in Netbeans/Ubuntu 12.04 using OpenJdk. I have

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.