Reputation: 109
My Problem: When I enter this piece of script in jcreator, it says illegal start of expression for (public String subString). Is there another way to enter a substring?
public String subString;
int beginIndex;
int endIndex;
Upvotes: 0
Views: 878
Reputation: 11
Let me Clear that you want to only extract substring from any string then Follwing code can help you :
String name="Eagle Eye";
String s1=name.subString(2,5);
Output: "gle Ey"
Here, 2 stands for Starting position and 5 for Length of substring.
Upvotes: 0
Reputation: 63560
If you mean that you wrote this inside a method, then you must remove the public
keyword. Visibility is assigned to class members, not local variables.
Upvotes: 3