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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:58:25+00:00 2026-05-29T09:58:25+00:00

Hi I converted my arraylist into an array so I can use it to

  • 0

Hi I converted my arraylist into an array so I can use it to display its elements in a JTable but nothing is displaying. It is giving me an error (error is explained in code comments). I just want to have one column only which displays values from this array. Can someone guide me in the correct direction? Thanks

Here is my code:

private static class EnvDataModel extends AbstractTableModel {

    private static final long serialVersionUID = 1L;

    private static ArrayList<Integer> list = new ArrayList<Integer>();
    private Object age[];

…

    public EnvDataModel() {
        age=list.toArray();
    }

    public String getColumnName(int col) {

            return "Age";
    }

    public int getColumnCount() {
        return 1;
    }

    public int getRowCount() {
        return list.size();
    }

    public Object getValueAt(int row, int col) {
            // Error message The method get(int) in the type ArrayList<Integer> is not applicable for the arguments (Object)
            return list.get(age[row]);  
    }
}
  • 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-29T09:58:26+00:00Added an answer on May 29, 2026 at 9:58 am

    1) ArrayList in the AbstractTableModel returns Column, please read tutorial about JTable how TableModel works

    2) you can change ArrayList<Integer> to the Vector<Vector<Integer>> or Interger[][], then you don’t need to define for AbstractTableModel, only use default contructor for JTable

    JTable(Object[][] rowData, Object[] columnNames)

    or

    JTable(Vector rowData, Vector columnNames)

    3) add Integer value to the DefaultTableModel

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

Sidebar

Related Questions

I have an array of strings. How can I convert it to System.Collections.ArrayList?
what is the correct way of injecting a byte array into an arraylist? private
i have this arraylist and i want to put the data in array.but i
In Java how do you convert a ArrayList into a two dimensional array Object[][]?
I have an ArrayList<Double> , the values of which are converted into slices of
Is there a more elegant solution to convert an ' Arraylist ' into a
I converted an old cvs repository into mercurial via hg convert . Everything seemed
'??' gets converted into '^' if I compile mn VC++ program and run it
Recently I converted a Swing application to Webstart. The process was pretty straightforward, but
I'm trying to write a function that returns an Array that I can pass

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.