Calling methods and constructors from main method

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Oct 2009
Posts: 4
Reputation: pwk064 is an unknown quantity at this point 
Solved Threads: 0
pwk064 pwk064 is offline Offline
Newbie Poster

Calling methods and constructors from main method

 
-1
  #1
Oct 17th, 2009
Here is my Main method - calling Display. I am getting an error message, I don't know what I am missing. Any suggestions?


public class Student
{
private int studentID;
private double studentGPA;

public Student()
{
studentID=100;
studentGPA=3.0;
}


public Student(int id, double gpa)
{

studentID=id;
studentGPA=gpa;
}

public void AssignValues(int id, double gpa)
{
studentID=999;
studentGPA=3.75;
}

public void Display(int id, double gpa)
{
System.out.println("Student ID:"+" "+studentID);

System.out.println("Student GPA:"+" "+studentGPA);

}
}




public class DisplayStudent
{

public static void main(String[] args)
{

Student IDNGPA = new Student();
IDNGPA.Display();



}

}


Error message: DisplayStudent.java:11: Display(int,double) in Student cannot be applied to ()
IDNGPA.Display();
^
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,415
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 256
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven
 
1
  #2
Oct 17th, 2009
You are calling the ethod without any arguments, but the method is designed to take an int and a double, so give it an int and a double.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC