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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:08:16+00:00 2026-06-04T08:08:16+00:00

My program contains 3 classes Student , Aplt and Aplt3 classes import java.applet.Applet; import

  • 0

My program contains 3 classes
Student , Aplt and Aplt3 classes


import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class Student {

    String name;
    int mark;

    Student(String name, int mark) {
        this.name = name;
        this.mark = mark;
    }
} 

student class with constructor

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.TextFiEld;
import java.awt.event.ActioNevent;
import java.awt.event.ActionListener;

public class Aplt extends Applet {

    TextField tf[] = new TextField[2];
    Student prs[] = new Student[0];
    ActionListener ins;

    public void init() {
        tf[0] = new TextField("name?", 10);
        tf[1] = new TextField("mark", 5);
        add(tf[0]);
        add(tf[1]);
        tf[1].addActionListener(ins = new Ins());
    }

    class Ins implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            String n = tf[0].getText();
            int nt = Integer.parseInt(tf[1].getText());
            Student help[] = new Student[prs.length + 1];
            System.arraycopy(prs, 0, help, 0, prs.length);
            help[help.length - 1] = new Student(n, nt);
            prs = help;
            tf[0].setText("next name");
            tf[1].setText("next mark");
            repaint();
        }
    }

    public void paint(Graphics g) {
        for (int i = 0; i < prs.length; i++) {
            g.drawString(prs.name, 10, 50 + 12 * i);
            g.drawString(prs.mark + "", 130, 50 + 12 * i);
        }
    }
}

here is aplt class. class lists us given names and marks

import java.applet.Applet;
import java.awt.Button;
import java.awt.event.*;

public class Aplt3 extends Aplt {

    Button b1, b2;

    public void init() {
        super.init();
        b1 = new Button("remove");
        b1.addActionListener(new B1());
        add(b1);
    }

    class B1 implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            int i;
            for (i = 0; i < prs.length; i++) {
                Student help[] = new Student[prs.length - 1];
                System.arraycopy(help, 0, help, 0, help.length);
            }
            repaint();
        }
    }
}

aplt3 class. Here I want to delete last element of array when I click to remove button, but it doesn’t happen.

  • 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-04T08:08:17+00:00Added an answer on June 4, 2026 at 8:08 am

    Here is the code you use to add a student:

    Student help[] = new Student[prs.length+1]; 
    System.arraycopy(prs, 0, help, 0, prs.length); 
    help[help.length-1]= new Student (n,nt); 
    prs=help; 
    

    Just use the same idea to remove one:

    Student help[] = new Student[prs.length-1]; 
    System.arraycopy(prs, 0, help, 0, help.length); 
    prs=help; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program with a class that contains a public enum, as follows:
I have two classes, a Teacher class and a Student class. In my program
Lets say we have a program which contains such classes: public interface AbstractItem {
Below program contains two show() functions in parent and child classes, but first show()
My program contains a child of a widget class, and the paint() function is
I have the following classes [Serializable()] public class ColumnList { public ColumnList() { ListOfColumns
I have a class that I writes iCal events, and it contains nested classes
My application jar contains classes from swing-layout.jar which contains free layout manager for java
So assume I have one class named Program which contains my whole program of
I am trying to run a program with two files. file1 contains two classes

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.