Results 1 to 2 of 2
  1. #1
    JavaNovice1 is offline Member
    Join Date
    Nov 2011
    Rep Power

    Default Cannot instantiate the type

    Hi guys, can someone please tell me what I'm doing wrong here? I'm using Eclipse and getting the following error:

    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    Cannot instantiate the type Person

    at ie.ds.personApp.CrecheApp.registerPerson(CrecheApp .java:50)
    at ie.ds.personApp.CrecheApp.main(
    For this program I have a person and child class extending from an abstract parent class...I am a complete newbie to java!!Any help appreciated..

    public class CrecheApp {DecimalFormat df = new DecimalFormat("#.##");

    int count=0;
    static int full = 3;
    static Person[] crecheArray = new Person[full];
    int i = 0;

    Icon blankIcon = new ImageIcon();

    public void registerPerson(Person[] creche) {

    Double cost;
    Icon createPerson = new Utilities().createImageIcon("images/logo.jpg","Logo");

    String s1 = "First name:";
    String s2 = "Surname:";
    String s3 = "Gender:";
    String s4 = "Parent or child:";

    JTextField firstname = new JTextField("");
    JTextField surname = new JTextField("");
    JTextField gender = new JTextField("");
    JTextField parentchild = new JTextField("");

    Object message[] = new Object[9];

    message[0] = createPerson;
    message[1] = s1;
    message[2] = firstname;
    message[3] = s2;
    message[4] = surname;
    message[5] = s3;
    message[6] = gender;
    message[7] = s4;
    message[8] = parentchild;

    JOptionPane.showConfirmDialog(null, message, "Register child",
    JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,blankIcon);

    cost= Double.parseDouble( parentchild.getText());
    crecheArray[i]=new Person(firstname.getText(),surname.getText(),gende r.getText());

    Its also showing up this line in the error window:

    if (myApp.count != myApp.full)
    myApp.registerPerson(crecheArray); else
    JOptionPane.showMessageDialog(null, "Creche is full");

  2. #2
    JavaNovice1 is offline Member
    Join Date
    Nov 2011
    Rep Power

    Default Re: Cannot instantiate the type

    I've read in a similar post that the problem was that the class's whose methods I am implementing in my public static void main are declared abstract...I have to have mine abstract so is there a solution to this??

Similar Threads

  1. How to instantiate Class, into jsp, java script
    By silvia in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 01-04-2014, 08:08 AM
  2. Replies: 8
    Last Post: 07-17-2011, 07:24 AM
  3. Cannot instantiate a type
    By Yeshol in forum Eclipse
    Replies: 14
    Last Post: 07-06-2011, 05:03 PM
  4. Replies: 0
    Last Post: 06-21-2011, 02:02 AM
  5. [SOLVED] Unable to instantiate class?
    By xcallmejudasx in forum New To Java
    Replies: 1
    Last Post: 11-03-2008, 04:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts