I'm trying to create a String Method that will take in a String as an argument. I am also creating another method that will return the value of that method anytime. I thought this was the correct way to do it.
public String ProvidedDate (String providedDate) {
String endDate = new String();
endDate = providedDate;
}
public String EndDate() {
return endDate;
}
This is apex on Salesforce btw but it's basically Java. It gives me an error saying "Type cannot be constructed:String". Any ideas where I"m going wrong?
I suspect it's complaining about the
String endDate = new String();
You don't really need to do that. Just make it
String endDate = providedDate;
and you'll be good to go. In general (in Apex but also in C# and Java) you don't usually need to explicitly construct String objects.