> This is the error I get:
... and it tells you everything you need to know...
> 1 error found:
> File: C:\JBuilder3\myprojects\PostCardDemo.java [line: 9]
> Error: cannot resolve symbol
> symbol : constructor PostCard (java.lang.String)
> location: class PostCard
Here you create a postcard via a constructor that accepts two "String"
parameters...
> PostCard p1 = new PostCard("Vanna", text);
Here you create a postcard via a constructor that accepts ONE "String"
parameter...
> PostCard p2 = new PostCard(text);
and here you again create a postcard via a constructor that accepts two
"String" parameters...
> PostCard p3 = new PostCard("Sweetie",
> "\tI'm miserable without\n" +
> "you. It's been raining all week.\n" +
> "I can't wait to get back home.");
Lets look at your "PostCard" class
> class PostCard {
> public String recipient;
> public String content;
Here is your "PostCard" constructor that accepots two strings...
> public PostCard(String r, String t) {
> recipient = r;
> content = t;
> content = recipient + content;
> }
but where is the one that accepts only one string? That seems to be
missing, and java tells you that it cannot find a constructor with the
parameter signature that you use for "PostCard" p2.
HTH
Piet
> This is the error I get:
> 1 error found:
[quoted text clipped - 56 lines]
> //return PostCard("[Dear " + recipient +"]");
> //}
If you look at the ninth line of your program, 'PostCard p2 = new
PostCard(text);', you'll see that it is trying to instantiate the PostCard
class with only a single String parameter. You don't have a constructor for
this class that expects a single String parameter.
You can resolve the problem in either of two ways:
- change the instantiation to pass two Strings; that will result in your
existing PostCard constructor being used
- create an additional constructor for the PostCard class that requires only
a single String parameter; in that case, the new constructor will be used.
Rhino