Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

ArrayList

Featured Replies

How can I add elements to a arraylist(I have 5 attributes to add to the arraylist,thoose should be added as the user type them), then save them to a file and be able to read the elements

from the file again.

I apriciate all help!

We cant reply your question if we dont know which programming language you use!

  • Author

Oh sorry...I have forgotten to say wich language.. it`s Java.

It depends on what you store in the ArrayList.

I think if it are Strings you could write them to a file, each element a new line something like that.

  • Author

I have managed to add elements to the ArrayList that I have created. But now I have problems to get the elements that I have stored. For the moment they are not stored in any file, only in the buffer when I execute the program. I have 5 attributes that I store, 4 are String, 1 is int.

This is how I have tried to get them:(Arrangements is the arraylist)

for (int i = 0; i < Arrangements.size(); i++)

{

System.out.println(Arrangements.get(i));

}

You can better use an Iterator, this class can also handle other collections than ArrayLists.

Iterator it = Arrangements.iterator();
while(it.hasNext()) {
System.out.println(it.next());
}

nm.. looked right over the list part :unsure:

Edited by RayOK

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.