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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:10:00+00:00 2026-05-27T05:10:00+00:00

I know C/C++/C#/ActionScript/PHP and have worked in all of them. As per my Knowledge

  • 0

I know C/C++/C#/ActionScript/PHP and have worked in all of them. As per my Knowledge we generally initialize object as

Object obj = new Object();

Java does the same most of the times but yesterday while working with Netbeans and JTable swing control, IDE generated this code which kind of looks a bit strange to me. Any explanation of how is it initializing an object? What’s the {..} part after new DefaultTableModel(..)?

_model = new DefaultTableModel(
     new Object [][] {
     },
     new String [] {
         "Id", "Project Title", "Start Date", "Deadline", "Description", "PercentDone"
     }) {
         Class[] types = new Class [] {
             java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
         };
         boolean[] canEdit = new boolean [] {
             false, false, false, false, false, false
         };

         @Override
         public Class getColumnClass(int columnIndex) {
              return types [columnIndex];
         }

         @Override
         public boolean isCellEditable(int rowIndex, int columnIndex) {
             return canEdit [columnIndex];
         }
     };
  • 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-27T05:10:00+00:00Added an answer on May 27, 2026 at 5:10 am

    It’s called an anonymous class, combining class definition and instantiation. Links:

    • http://mindprod.com/jgloss/anonymousclasses.html
    • http://docstore.mik.ua/orelly/java-ent/jnut/ch03_12.htm
    • http://en.wikibooks.org/wiki/Java_Programming/Nested_Classes#Anonymous_Classes
    • Is usage of anonymous classes in Java considered bad style or good?

    Line by line explanation:

    // creates a new instance of the DefaultTableModel class and assigns it
    // to a previously declared variable named _model.
    // Note that contrary to C++, starting a variable name with an underscore is
    // legal but discouraged as a convention in Java
    // (http://docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html)
    _model = new DefaultTableModel(
    
        // this is first parameter to the DefaultTableModel constructor taking
        // a two-dimensional array of Objects as the first parameter, and an
        // array of Objects as the second. This creates an empty 2D array.
        new Object [][] {
        },
    
        // this is the second parameter to the DefaultTableModel constructor.
        // It creates an array of Strings initialized with the provided values
        new String [] {
            "Id", "Project Title", "Start Date", "Deadline", "Description", "PercentDone"
        })
    
            // start of the redifinition of the DefaultTableModel class
            {
    
                // creates a member variable named types at the default visibility.
                // This member is an array of Class objects, initialized with the
                // provided values
                Class[] types = new Class [] 
                    java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
                };
    
                // creates a member variable named canEdit at the default visibility.
                // This member is an array of booleans, all initialized to false.
                boolean[] canEdit = new boolean [] {
                    false, false, false, false, false, false
                };
    
                // annotation used by IDEs and the compiler specifying that the
                // method that follows overrides a method in the DefaultTableModel
                // class. If the methods does not actually override such a method,
                // an error will be generated (e.g. due to a spelling mistake in the
                // method name or the wrong parameters being declared)
                @Override
    
                // override of the default getColumnClass method
                public Class getColumnClass(int columnIndex) {
                    return types [columnIndex];
                }
    
                // see explanation above
                @Override
    
                // override of the default isCellEditable method
                public boolean isCellEditable(int rowIndex, int columnIndex) {
                    return canEdit [columnIndex];
                }
    
        // end of the anonymous class
        };
    // end of the constructor call and assignment to _model statement.
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have vast programming knowledge; C++/C#/ActionScript/ASM/PHP..... so learning the language of SilverLight itself isn't
I have a CircleButton class in Actionscript. I want to know when someone externally
Every programming language I know (Perl, Javascript, PHP, Python, ASP, ActionScript, Commodore Basic) uses
I want to create flex/actionscript directory view for my files with php/mysql. I have
Do you know any chess move validation library for ActionScript 3 ? I have
Does anyone know if there's a Flash (ActionScript) library for providing back button support?
I know of FlashDevelop for windows but how about developing actionscript or haxe on
Is there a ActionScript-version of JavaScript's Canvas.clearRect()? I only know graphics.drawRect(...) which allows me
i wanted to know that using actionscript, is it possible to send email and
I've been developing some APIs for communication between some PHP services and ActionScript 3.

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.