Results 1 to 9 of 9
  1. #1
    everlast88az is offline Member
    Join Date
    Nov 2008
    Posts
    11
    Rep Power
    0

    Default Problems implementing Java string methods

    Hi,

    I am trying to get the substring method available to my program.
    I am using netbeans IDE and I want to parse some strings with javas string library. I thought this lib (Java.Lang.String) was part of the SDK anyway but I downloaded the JAR files and then added them to my project in the right spot but the methods I am trying to access are still not available. Any ideas why this isn't showing up?

    Here is a basic example of what I want to do

    import java.lang.*;

    String blah = "fjdfdfoijer";
    String blahblah = blah.substring(2,6);


    but I can't acces the .substring() method!!:eek:

    curses!

    Thanks,
    in advance

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    I can't acces the .substring() method!
    What do you mean by "access"?
    If you get errors, copy and paste the full text here.

  3. #3
    everlast88az is offline Member
    Join Date
    Nov 2008
    Posts
    11
    Rep Power
    0

    Default

    its like the program has no idea about the import statement I have above
    import java.lang.*;

    Of which the substring method is part of that class. So I should have access to the method, but I do not. The error is below. Yes I have included the package, yes it is correct. If I am not mistaken the java.lang package is part of the sdk so I shouldn't even have needed that...

    symbol : method substring(int,int)
    location: class java.lang.String[]
    Description2.substring(2,10);
    1 error
    BUILD FAILED (total time: 0 seconds)

  4. #4
    everlast88az is offline Member
    Join Date
    Nov 2008
    Posts
    11
    Rep Power
    0

    Default

    java:87: cannot find symbol
    thats the error

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    location: class java.lang.String[]
    Why does this have array notation and your example does NOT.
    Could you post the ACTUAL statement that is causing the problem, along with the definition for the variable that is used in that statement?
    When you post an error message, please post ALL of the message. You left off the first line and the line with the source:
    Java Code:
    Test5.java:7: cannot find symbol
    symbol  : method substring(int,int)
    location: class java.lang.String[]
          anArray.substring(1,2);
    The above is the full text of an error mesage I get.

    The import statement has nothing to do with the error.

  6. #6
    everlast88az is offline Member
    Join Date
    Nov 2008
    Posts
    11
    Rep Power
    0

    Default

    AH! I got it I wasn't using array notation I am a spaz.

    thanks for your help guy in MO.
    :D

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    I think he means the [i] in anArray[i].substring(1,2);

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Replies: 2
    Last Post: 09-18-2008, 07:30 AM
  2. Problems with readLine() and calling methods
    By peachyco in forum New To Java
    Replies: 2
    Last Post: 11-24-2007, 07:44 AM
  3. Replies: 0
    Last Post: 11-20-2007, 04:59 PM
  4. Implementing a red-black tree in java
    By baltazar in forum New To Java
    Replies: 1
    Last Post: 07-13-2007, 08:37 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
  •