NERO
NERO

Reputation: 1

Eclipse (java) - Cannot be resolved to a type

So im getting the msg "Person cannot be resolved to a type" at Person p1,p2... and at P1,p2,p3 = new person...

Have been googling like crazy but im very new with programming and with Eclipse so im really lost at fixing this problem. I tried using this code with Sublime Text and i did actually get the same errors so is maybe the actual code the problem or is Eclipse bugging?

Thanks!

public class Ptest2main2{
public static void main(String[] arg) {

    Person p1, p2, p3;

    p1 = new Person ("Kalle anka", "123 ocean drive, orlando florida", 79);
    p2 = new Person ("Wile E Cotoye", "15 Acme Road, Hollywood California", 67);
    p3 = new Person ("Elmer Fudd", "Loony Toones Ave, bubank, California");

    System.out.printf("\n%-18s%-40s%s\n", "namn", "adress", "alder");
    System.out.printf (p1.skrivUt() + '\n');
    System.out.printf (p2.skrivUt() + '\n');
    System.out.printf (p3.skrivUt() + "\n\n");

 }
}

Upvotes: 0

Views: 7208

Answers (1)

chiastic-security
chiastic-security

Reputation: 20520

Person is a class that you're trying to create instances of.

It isn't a standard Java class, which means you need to define it somewhere. Either you just haven't got a Person class and you need to create one, or you've got one, but you haven't imported it into this class.

Look at the symbol to the left of the error line in Eclipse. If it's a red cross, that means Eclipse can't think of any way of getting you out of this. If it's a lightbulb superimposed on a red cross, you can click it to get ideas for how to solve it. If there's a Person class somewhere that you haven't imported, then Eclipse should help you find it.

Upvotes: 2

Related Questions