1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Luba_88 [7]
3 years ago
14

A teacher wants to create a list of students in her class. Using the existing Student class in this exercise. Create a static Ar

rayList called classList that adds a student to the classList whenever a new Student is created. In the constructor, you will have to add that Student to the ArrayList.

Computers and Technology
1 answer:
aleksandr82 [10.1K]3 years ago
4 0

Answer:

Check the explanation

Explanation:

CODE:-

import java.util.ArrayList;

class Student

{

  private String name;

  private int grade;

  private static ArrayList<Student> classList = new ArrayList<Student>();

 

  public Student(String name, int grade)

  {

      this.name = name;

      this.grade = grade;

      classList.add(this);

  }

 

  public String getName()

  {

      return this.name;

  }

 

  /*Don't change the code in this method!

  This method will print out all the Student names in the classList Array

  */

  public static String printClassList()

  {

      String names = "";

      for(Student name: classList)

      {

          names+= name.getName() + "\n";

      }

      return "Student Class List:\n" + names;

  }

}

public class ClassListTester

{

  public static void main(String[] args)

  {

      //You don't need to change anything here, but feel free to add more Students!

      Student alan = new Student("Alan", 11);

      Student kevin = new Student("Kevin", 10);

      Student annie = new Student("Annie", 12);

      Student smith = new Student("Smith", 11);

      Student kane = new Student("Kane", 10);

      Student virat = new Student("Virat", 12);

      Student abd = new Student("ABD", 12);

      Student root = new Student("Root", 12);

      System.out.println(Student.printClassList());

  }

}

Kindly check the attached image below.

You might be interested in
What type of lens was used to take this picture?
Leona [35]

Fish-eye because this is how you would see through a "fish eye" point of view in a rounded tank that is commonly used.

May I please have brainliest

4 0
3 years ago
Describe the objectives of e-commerce ?​
AnnZ [28]

Answer: eCommerce is to reach the more and right customers at the right time so that more orders can be placed and in turns, high revenue can be generated.

Explanation:

5 0
3 years ago
Why don't I have friends?
Papessa [141]

Answer:

maybe you do not ask for them i will be your friend.

Explanation:

7 0
3 years ago
Read 2 more answers
Best gaming chairs under 150 (facts)​
adelina 88 [10]

Answer:

IKEA ÖRFJÄLL/SPORREN Swivel Chair, White, Vissle Light Green 191.623.75

Explanation:

it's Ikea

7 0
3 years ago
____ is the control or suppression of what can be accessed, published, or viewed on the internet.
arlik [135]
It is internet censorship
6 0
3 years ago
Other questions:
  • I need a idea of a origami for my coding class and it needs to be easy to make
    15·2 answers
  • Which of the following protects against cave-ins? A. All answer choices protect against cave-ins B. Shielding C. Shoring D. Slop
    5·2 answers
  • The part of the poppet valve that contacts the valve seat is called the?
    10·2 answers
  • PLEASE HELP ME ASAP!!!!
    11·1 answer
  • How do I insert a row above the selected row in between row and row 2 revenue xls
    5·1 answer
  • What is the purpose of the new window command
    6·1 answer
  • What type of activities are performed with the help of the software used in hospitals?
    7·2 answers
  • ____________ are the in – built functions that perform a particular pre – defined task when used in a computer program.
    13·1 answer
  • What type of information is appropriate for headers and footers? Check all that apply.
    5·2 answers
  • The term used to describe whereby old and new media are available via the integration of personal computers and high speed satel
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!