Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I'm getting the error:

Student.java:96: error: cannot find symbol
s1.display();
^
symbol: variable s1
location: class Student
1 error

What I have tried:

Java
public class Student extends Person {
	
	private int studentId; 
	private String major; 
	private double GPA; 
	
	public Student() { 
		// TODO Auto-generated constructor stub 
		super(); 
		this.studentId = 0; 
		this.major = "";
		GPA = 0.0; 
	}
	
	/**
		@param firstName 
		@param lastName 
		@param address 
		@param email 
		@param studentId 
		@param major 
		@param gPA 
	*/
	
	public Student(int studentId, String firstName, String lastName, 
	String Address, String email, String major, double gPA) {
		super(firstName, lastName, Address, email); 
		this.studentId = studentId; 
		this.major = major;
		GPA = gPA; 
	}
	
	/**
		*@return the studentId
	*/
	public int getStudentId() { 
		return studentId;
	}
	
	/**
		*@return the major
	*/
	public String getMajor() {
		return major;
	}
	
	/**
		*@return the gPA
	*/
	public double getGPA() {
		return GPA;
	}
	
	/**
		*@param studentId
		*the studentId to set
	*/
	public void setStudentId(int studentId) {
		this.studentId = studentId;
	}
	
	/**
		*@param major
		*the major to set
	*/
	public void setMajor(String major) { 
		this.major = major; 
	}
	
	/**
		*@param gPA
		*the gPA to set
	*/
	public void setGPA(double gPA) { 
		GPA = gPA; 
	}
	
	public void display() {
		// print the student details 
		System.out.println("STUDENT ID : " + this.studentId); 
		System.out.println("MAJOR: " + this.major); 
		System.out.println("GPA : " + this.GPA); 
		super.display(); 
	}
	
	public static void main(String[] args) { 
		Student sl; 
		sl = new Student(900077661, "Bill", "Clinton", "70 Bowman St. South Windsor, CT 06074", 
		"bc@msn.com", "CS", 3.5); 
		s1.display();
	}
}
Posted
Updated 26-Mar-18 17:09pm
v2

1 solution

You define Student sl, but you using s1.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900