Here i am going to show you the use of get set array in java.
package setgetarray;
import java.util.Scanner;
public class SetGetArray {
int i;
Scanner sc= new Scanner(toString());
int rollNo[]=new int[2];
float marks[] = new float[2];
String info[]=new String[2];
public void setInfo(){
System.out.println("Enter the student no:");
//this.n= sc.nextInt();
for (i=0;i<2;i++){
System.out.println("student roll:");
sc.nextInt();
System.out.println("student marks");
sc.nextFloat();
System.out.println("student info");
sc.nextLine();
}
}
public void getInfo(){
System.out.println("student info:");
for(i=0;i<2;i++){
System.out.println("student roll:"+rollNo);
System.out.println("student marks"+marks);
System.out.println("student info"+info);
}
}
}
package setgetarray;
import java.util.Scanner;
public class SetGetArray {
int i;
Scanner sc= new Scanner(toString());
int rollNo[]=new int[2];
float marks[] = new float[2];
String info[]=new String[2];
public void setInfo(){
System.out.println("Enter the student no:");
//this.n= sc.nextInt();
for (i=0;i<2;i++){
System.out.println("student roll:");
sc.nextInt();
System.out.println("student marks");
sc.nextFloat();
System.out.println("student info");
sc.nextLine();
}
}
public void getInfo(){
System.out.println("student info:");
for(i=0;i<2;i++){
System.out.println("student roll:"+rollNo);
System.out.println("student marks"+marks);
System.out.println("student info"+info);
}
}
}