can constructors actually return Strings?
Posted
by elwynn
on Stack Overflow
See other posts from Stack Overflow
or by elwynn
Published on 2009-08-28T14:23:02Z
Indexed on
2010/05/18
22:10 UTC
Read the original article
Hit count: 127
Hi all,
I have a class called ArionFileExtractor in a .java file of the same name.
public class ArionFileExtractor {
public String ArionFileExtractor (String fName, String startText, String endText) {
String afExtract = "";
// Extract string from fName into afExtract in code I won't show here
return afExtract;
}
However, when I try to invoke ArionFileExtractor in another .java file, as follows:
String afe = ArionFileExtractor("gibberish.txt", "foo", "/foo");
NetBeans informs me that there are incompatible types and that java.lang.String is required. But I coded ArionFileExtractor to return the standard string type, which is java.lang.string.
I am wondering, can my ArionFileExtractor constructor legally return a String?
I very much appreciate any tips or pointers on what I'm doing wrong here.
© Stack Overflow or respective owner