I have a line of data that contains various non-delimited field values.
X55655PlateX58745CupX52689SaucerX52459SpoonH59876KnifeX59866Fork
I am trying to use substring and indexOf to pull the data, using a series of statements similar to the one below.
dataField1 = substring.inputLine((indexOf("Marker1: ")+9),(inputLine.indexOf("Marker2:")-1));
I keep getting error:cannot find symbol
pointing to substring
. Typically, this is when I've not called the proper java packages in, but I'm using the following:
import java.util.*;
import java.io.*;
import java.nio.file.*;
import java.lang.*;
and java.lang.*
is where the string methods live, right? I'm also initializing String datafield1 = "";
.
dataField1 = inputLine.Substring((indexOf("Marker1: ")+9),(indexOf("Marker2:")-1));
results in indexOf receiveing the cannot find symbnol
error. But if indexOf is ALSO a method of String, where would that need to go?
My program appears to be using the proper syntax substring(x,y)
as noted in the java documentation, however, there are no real-world examples applicable to my troubleshooting.
I've reviewed this article but it doesn't quite get me to wrap my head around the concepts any better.
Why dioes this keep erroring out, and how can I prevent it?
substring
should be called on a String object. Otherwise it is looking for a method called substring
in your current class.