1

When I use the code for the GUID generator which is present here:

GUID Generator

I am getting this error Method does not exist or incorrect signature: StringUtils.charAt(String, Integer) at line 27 column 28

What why do I get this error?

5
  • 1
    This is not a question as you have phrased it, and you didn't link to the other question correctly — if you have edit privileges can you fix it up? Otherwise I can, but this is a low quality question and is likely to be downvoted.
    – Matt Lacey
    Commented Nov 7, 2012 at 7:43
  • modified the code and it was saved successfully....Thanks for ur replies...
    – Eagerin Sf
    Commented Nov 7, 2012 at 7:51
  • if one of the answers showed you what to change you should accept that answer — it's a core part of how the StackExchange model works. Plus you did fix the link but didn't make the question a question :)
    – Matt Lacey
    Commented Nov 7, 2012 at 9:27
  • Before seeing the answers that are posted I got my mistake rectified...My fault here is without checking the code properly I have posted the Question.Moreover thought of deleting the question but already got the answers and unable to delete it.Sorry for the inconvenience
    – Eagerin Sf
    Commented Nov 7, 2012 at 9:49
  • No worries mate, just so you know if you find the answer yourself it's perfectly acceptable to post your own asnwer to the question too. The idea is to build up a useful Q&A resource for others, though your question as it stands is unlikely to help others.
    – Matt Lacey
    Commented Nov 7, 2012 at 11:11

2 Answers 2

2

In the code in the question you linked to, the charAt() method is included in the class, not in a class called StringUtils, so unless you've put it in a class called StringUtils you'll need to remove that part from the call to the method.

Alternatively, if you have put it in a class called StringUtils, the problem may be that you haven't created an instance of the class:

StringUtils utils = new StringUtils();
utils.CharAt(aString, 4);

In which case, you probably meant to make the method static anyway and forgot the static keyword in the code (the asterisks are for emphasis, they're not part of the code!):

global **static** String charAt(String str, Integer index)

All that aside, if you couldn't fix this yourself then chances are you need to learn a bit more about writing code in Apex before trying to build large pieces of functionality on the platform.

1
  • That's correct. As I mentioned in the answer, the code was "cobbled" from a bunch of sources. I changed the posted code to avoid the collision with existing charAt implementation(s)
    – Paul Sasik
    Commented Nov 7, 2012 at 14:44
1

That's most likely because this GUID generator is cannibalized out of Apex-Lang project (a bunch of utility libraries for SF, in my opinion a bit obsolete in Winter'13).

Try to replace the call with something like yourStringVariable.mid(yourIndexInteger, 1);?

1
  • That's correct. As I mentioned in the answer, the code was "cobbled" from a bunch of sources. I changed the posted code to avoid the collision with existing charAt implementation(s)
    – Paul Sasik
    Commented Nov 7, 2012 at 14:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .