Results 1 to 9 of 9
- 11-04-2008, 09:33 PM #1
Member
- Join Date
- Nov 2008
- Posts
- 11
- Rep Power
- 0
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
- 11-04-2008, 11:48 PM #2
What do you mean by "access"?I can't acces the .substring() method!
If you get errors, copy and paste the full text here.
- 11-05-2008, 01:53 AM #3
Member
- Join Date
- Nov 2008
- Posts
- 11
- Rep Power
- 0
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)
- 11-05-2008, 02:22 AM #4
Member
- Join Date
- Nov 2008
- Posts
- 11
- Rep Power
- 0
java:87: cannot find symbol
thats the error
- 11-05-2008, 02:23 AM #5
Why does this have array notation and your example does NOT.location: class java.lang.String[]
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:
The above is the full text of an error mesage I get.Java Code:Test5.java:7: cannot find symbol symbol : method substring(int,int) location: class java.lang.String[] anArray.substring(1,2);
The import statement has nothing to do with the error.
- 11-05-2008, 02:48 AM #6
Member
- Join Date
- Nov 2008
- Posts
- 11
- Rep Power
- 0
AH! I got it I wasn't using array notation I am a spaz.
thanks for your help guy in MO.
:D
- 11-05-2008, 04:25 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 11-05-2008, 01:53 PM #8
I think he means the [i] in anArray[i].substring(1,2);
- 11-06-2008, 04:17 AM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Ah, that means he doesn't get the correct element.
Similar Threads
-
Error: cannot resolve symbol' on Person (java.lang.String, java.lang.String)
By baltimore in forum New To JavaReplies: 2Last Post: 09-18-2008, 07:30 AM -
Problems with readLine() and calling methods
By peachyco in forum New To JavaReplies: 2Last Post: 11-24-2007, 07:44 AM -
Using java.util.Scanner to search for a String in a String
By Java Tip in forum Java TipReplies: 0Last Post: 11-20-2007, 04:59 PM -
Implementing a red-black tree in java
By baltazar in forum New To JavaReplies: 1Last Post: 07-13-2007, 08:37 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks