Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Using an ArrayList to hold Data

$
0
0
Here is my code:
import java.util.ArrayList;

public class Data { public static void main(String args[]) {

	Data [] Names = {"Fred", "Jane", "Zoe"};


ArrayList<Data> array_list = new ArrayList<Data>();


for (Data x: Names)
array_list.add(x);  



Hey there, I'm new to java and to Arrays.

I need to add Data such as the name and age to an ArrayList using the add method, and then display it. But Data cannot be converted into a String (obviously).
I am really quite stuck here, any help would be great thanks. :bigsmile:/>

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>