#help

32 messages ยท Page 1 of 1 (latest)

quaint lionBOT
#

โŒ› This post has been reserved for your question.

Hey @dusty garden! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

idle galleon
#

so you want to, when pressing 5, list everything you added previously?

#

and you want to know how you can get the data you added previously into there

idle galleon
#

well you've done something similar before

#

the scanner is available and changes over each loop iteration, no?

#

just put a list outside of the while loop, modify it from inside the loop when you need to, then read it out in the loop when you need to

#

have you done arrays yet

#
int[] whatever = new int[4];
for(int i = 0; i < 4; i++) whatever[i] = i;
System.out.println(whatever[3]);

what will this print

#

exactly, the array's being modified by the loop

#

you can apply the same concept here, have some data type outside of the loop, modify the variable inside the loop and read it out when you need it, optionally also inside of the loop

#

i dont know what more i can tell you tbh, you just need to define a variable that stores what you want to store outside of the loop, modify and read it inside the loop

#

that'd be the second slot, array indices start at 0

#

4 elements in the array
index 0 would be the first element,
index 1 the second,
etc

#

index 3 is the fourth element, so the last

#

which is 3

quaint lionBOT
#

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.

idle galleon
#

you put the object storing the data outside of the loop, then update it and read from it inside the loop

#

no

#

no simpler one

#
List<String> names = new ArrayList();
while (true) {
  int action = reader.readInt();
  reader.readLine();
  if (action == 0) { // add user
    names.add(reader.readLine());
  } else if (action == 1) { // list users
    for(String name : names) {
      System.out.println(name);
    }
  }
}
#

cmon put some effort into it

#

i cant beam knowledge directly into your brain, read the code and try to understand it

#

yes

quaint lionBOT
#

๐Ÿ’ค Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.

hollow kite
#

nooo

#

if u really wanna be explained, i can just!@dusty garden ping me if u wanna

#

is ur problem solved btw?

#

by the code given above? ๐Ÿ‘€

#

wht do u think arraylist added to ur code ๐Ÿ˜‚

hollow kite