i am new with generics and i have a problem with creating an arrays of generic class.
if i have one and i want to create in a seperate main at the same java project generic array wich answer two diffrent types-string and integer.
can i put two difreent types the same array?
and is it ok to call the main like this:
public static <T> void main(String[] args) {
String name;
int grade;
int choice;
int count = 0;
String number;
System.out.println("press 1 if you like to save id as integer ,or press 2 to for a string ");
choice = s.nextInt();
Student<T>[] array = new Student[NUM_OF_STUDENTS];
if (choice == 1) {
System.out.println("please enter student name :");
s.nextLine();
name = s.nextLine();
while (!name.isEmpty() && count != NUM_OF_STUDENTS) {
System.out.println("please enter student #" + (count + 1) + " grade :");
grade = s.nextInt();
array[count] = new Student(count + 1, name, grade);
count++;
...
....