I'm trying to create a program that prompts the user to input the amount of students and their score and then prints it out. However im stuck at slots.get(i).inputData(); as i get

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
	Cannot invoke inputData() on the primitive type int

	at GradeBook.main(GradeBook.java:52)

some help would be greatly appreciated

import java.util.ArrayList;
import java.util.Scanner;

public class GradeBook {
public int sid;
public int q1;
public int q2;
public int q3;
public int q4;
public int q5;
public int response;

public GradeBook(int sid, int q1, int q2, int q3, int q4, int q5){
 	public void inputData(){
 		Scanner in= new Scanner(System.in);
		System.out.println("Enter 4 digit student ID");
		sid = in.nextInt();
		System.out.println("Enter score for quiz one");
		q1 = in.nextInt();
		System.out.println("Enter score for quiz two");
		q2 = in.nextInt();
		System.out.println("Enter score for quiz three");
		q3 = in.nextInt();
		System.out.println("Enter score for quiz four");
		q4 = in.nextInt();
		System.out.println("Enter score for quiz five");
		q5 = in.nextInt();
		ArrayList<Student> info= new  ArrayList<Student>();

		 info.add(new Student(sid, q1,q2,q3,q4,q5));
		 int a= info.size();
		 for(int x= 0; x<=a;x++){
	public static void main(String[] args) {
		Scanner in= new Scanner(System.in);
 		System.out.println("How many students do you wish to add? ");
		int response = in.nextInt();
		ArrayList<Integer> slots= new ArrayList<Integer>(response);
		 for(int i=0; i<=response;i++){
	public int getSid() {
		return sid;
	public void setSid(int sid) {
		this.sid = sid;
	public int getQ1() {
		return q1;
	public void setQ1(int q1) {
		this.q1 = q1;
	public int getQ2() {
		return q2;
	public void setQ2(int q2) {
		this.q2 = q2;
	public int getQ3() {
		return q3;
	public void setQ3(int q3) {
		this.q3 = q3;
	public int getQ4() {
		return q4;
	public void setQ4(int q4) {
		this.q4 = q4;
	public int getQ5() {
		return q5;
	public void setQ5(int q5) {
		this.q5 = q5;


public class Student extends GradeBook{

	public Student(int sid, int q1, int q2, int q3, int q4, int q5)

That's strange. Line 52 in the error message is blank in the code you posted.
What does the method slots.get(i) return? Is it an object with a method: inputData()?

Break up the compound statement into separate parts and println() the results of each part. Compound statement has more than one . in it

The erroneous line is Line 49 in the post, Your "slots" variable inside the main() method is an ArrayList of integers. So slots.get(i) returns an Integer object, and last I checked the javadocs of Integer class did not have any such method.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.