In: Computer Science
// importing all the packages required
import java.io.*;
import java.util.*;
class StoreData {
// creating Array List which store another Array List into it
static ArrayList<ArrayList<Object>> myArrayList = new ArrayList<>();
// storing In the Array List
public static void storeDataInArray(String course, int mark) {
// creating an Array list to store data
ArrayList<Object> temp = new ArrayList<>();
// storing data in temp Array List
temp.add(course);
temp.add(mark);
// storing the temp Array List into myArrayList
myArrayList.add(temp);
// printing the elements of Array List (myArrayList)
System.out.println(myArrayList + " Added success in the Array List");
}
// Main function
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// taking Course input from user
System.out.println("Enter the Course");
String course = sc.nextLine();
// taking mark input from user
System.out.println("Enter the Individual mark");
int mark = sc.nextInt();
// calling the function to store data
storeDataInArray(course, mark);
}
}
Some output snippets
If the answer was helpful don't forget to upvote it, It keeps me motivated.
Thank you for your time have a good day:)