here is the detail of the error:
Code:
Exception in thread "main" java.lang.NullPointerException
at com.univ.util.CommonUtility.create(CommonUtility.java:22)
at com.univ.process.CourseMethods.createCourse(CourseMethods.java:18)
at com.univ.process.Tester.main(Tester.java:36)
CourseMethods.java
Code:
package com.univ.process;
import com.univ.util.CommonUtility;
import com.univ.pojo.Course;
public class CourseMethods {
private Course course;
public void setCourse(Course course) {
this.course = course;
}
public void createCourse(){
System.out.println("createCourse is running");
CommonUtility cu = new CommonUtility();
cu.create(course);
System.out.println("createCourse is completed successfully");
}
}
Tester.java
Code:
package com.univ.process;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import com.univ.pojo.Course;
import com.univ.process.CourseMethods;
public class Tester {
public static void main(String[] args){
Date dte=null;
float courseFee=12000;
Course c = new Course();
CourseMethods cm = new CourseMethods();
DateFormat df = new SimpleDateFormat("dd/mm/yyyy");
try{
dte = df.parse("22/12/2009");
}catch(Exception e){
e.getMessage();
}
c.setCourseName("Diploma in Computing");
c.setCourseDesc("Diploma in Computing Description");
c.setCourseEffectiveDate(dte);
c.setCourseFee(courseFee);
c.setCourseUniversity("Curtin University Of Technology");
c.setCourseIsDeleted('0');
cm.setCourse(c);
cm.createCourse();
}
}