I have an array which store some data inside it. Inside the array there will be some data like this
Alluser[0] = John || 20 || Student;
Alluser[1] = Will || 19 || Student;
I wanted to split the data and arrange one user into one array. Something like this
user0[0] = John;
user0[1] = 20;
user0[2] = Student;
The number of user will constantly increase later on. But I don’t know how to constantly create new array for new user.
I tried something like this
for(int i=0;i<Alluser.length;i++){
String[] user[i]= Alluser[i].split("||");
}
I knew that String[] user[i] is wrong, I just don’t really the structure of the correct way of handling this issue. Any comment and answer will be highly appreciated.
Use OOP:
Create a
class Userand storeList<User> listOfUsers;In this case you’ll have a list of users and get access to each item, delete it or add new users.
and also you can iterate: