I’m new to Java. I want to create Java Array and insert data into it. I found this code:
ArrayList<SessionsArray> sessionList =
new ArrayList<SessionsArray>(
Arrays.asList( new SessionsArray("A0001", "Intel CPU", new BigDecimal("700.00"), 1),
new SessionsArray("A0002", "Harddisk 10TB", new BigDecimal("500.00"), 2),
new SessionsArray("A0003", "Dell Laptop", new BigDecimal("11600.00"), 8),
new SessionsArray("A0004", "Samsung LCD", new BigDecimal("5200.00"), 3),
new SessionsArray("A0005", "A4Tech Mouse", new BigDecimal("100.00"), 10)
));
How I can declare the Array in tho parts and insert and remove data form it? Something like this:
//declare the Array
ArrayList<SessionsArray> sessionList = new ArrayList<SessionsArray>();
//insert into Array
ArrayList<SessionsArray>(Arrays.asList( new SessionsArray("A0001", "Intel CPU", new BigDecimal("700.00"), 1),
new SessionsArray("A0002", "Harddisk 10TB", new BigDecimal("500.00"), 2),
new SessionsArray("A0003", "Dell Laptop", new BigDecimal("11600.00"), 8),
new SessionsArray("A0004", "Samsung LCD", new BigDecimal("5200.00"), 3),
new SessionsArray("A0005", "A4Tech Mouse", new BigDecimal("100.00"), 10)
));
Best wishes
**EDIT**
I want to use it because I want to get data from database and pass it to JSF page? Is there other way to pass data from database to JSF page?
**EDIT 2**
How I can remove just one element from the list for example only A0002?
Fixed for 1 by 1 add
In answer to your edit 2: how to remove the SessionsArray that contains “A0002”: