Java arraylist, inheritance, abstract class questions

Asked 2 years ago, Updated 2 years ago, 111 views

Hello, I am an undergraduate studying coding.

In the management class,

ArrayList<Member> members = newArrayList<Member>();

members.add (new member 1 (Hong Gil-dong, string, string, int);
members.add(new member 2 (gocheon, int);

I made the chords like this The string string int after Hong Gildong is the variable in member 1 The int after Gochun is the variable in member 2. Is there a way to modify the string string int and int in the management class?

Member class is an abstract class!

java arraylist inheritance abstract

2022-09-20 22:14

1 Answers

// Access the member 1 instance of Hong Gil-dong.
members.get(0).string1 = "Modify";
members.get(0).string2 = "Modify";
members.get(0).int = x;

// Access the member2 instance that is Gochun.
members.get(1).int = x;

If you are not asking how to use ArrayList, please upload the code for Member, Member1, Member2 Class.


2022-09-20 22:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.