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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:02:31+00:00 2026-05-13T00:02:31+00:00

I have a class that reads the state of what string is in a

  • 0

I have a class that reads the state of what string is in a JTextFeild (displayBox is the class in this case). The method sould read the state put it into an ArrayList (lastState in this case) and the be able to put it back into the JText feild when a method is called (returnState in this case)
displayBox is a object of class Jtextfeild declared and used in another class (Calculator class) I am trying to write an undo feature for a home work assignment. My question is this the correct way to go about the getting and setting of the array date, thanks. Code is below:

import java.util.*;
import java.awt.event.*;
import java.awt.*;
/**
 * Write a description of class Status here.
 * 
 * @author (Jason Sizemore ) 
 * @version (HW09 11-21-09)
 *  This is a class to get the status for the undo feature
 */
public class Status extends Calculator
{   
    //attributes
    private ArrayList<String> lastState;
    public String ls;

    public String rls;  
    //constructors

    public Status()
    {
        super();
        lastState = new ArrayList<String>(10);
    }

    //Methods
    public void copyState()
    {
        ls = displayBox.getText();
        lastState.add(ls);
        System.out.println(ls);
    }

    public String returnState()
    {
        //problem is here 
        int sizeOfArrayList; 
        sizeOfArrayList = lastState.size();
        rls = lastState.get(sizeOfArrayList);
        return rls;
    }
}
  • 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-13T00:02:31+00:00Added an answer on May 13, 2026 at 12:02 am

    To restate what Luno said, List.getSize() returns the count of elements in the List. The indexes start at 0, so the highest index you can ever get from a List is one less than the total number of elements.

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

Sidebar

Related Questions

Problem in words: For my application, I have a class that reads from a
I have a large-ish project that contains one class that reads from a file
I have a multi-R/W lock class that keeps the read, write and pending read
I am new to Java. I just read that class variables in Java have
I have class that looks like this: class A { public: class variables_map vm
I have class that represents users. Users are divided into two groups with different
I have a ConfigParameter SLSB that reads configuration values from the ejb-jar.xml file. This
I have a class that reads the written output of a Student[] array object
I have class that extend FragmentActivity in it I add fragment to layout as
I have class grades that I need to check if a specific grade is

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.