W
webbedaccess
Where did I go wrong? should the private variable str be a character,
or should cast?
cast the charAt to a string?
compile code below I get
incomparable types: char and Java.lang.String
class myGen implements Iterator<String>
{
private String str;
private int iToken;
public myGen(String s)
{
str = s.trim();
iToken= 0;
}
public boolean hasNext()
{
// I am trying to return true if there is more; otherwise false
// I am using a while loop to advance iToken until a non-space
is found.
// I am checking that iToken < str.length() before I test
while (iToken < str.length()) {
if (!(str.charAt(iToken) == " " )) {
return true; }
else {
return false;}
}
}
}
or should cast?
cast the charAt to a string?
compile code below I get
incomparable types: char and Java.lang.String
class myGen implements Iterator<String>
{
private String str;
private int iToken;
public myGen(String s)
{
str = s.trim();
iToken= 0;
}
public boolean hasNext()
{
// I am trying to return true if there is more; otherwise false
// I am using a while loop to advance iToken until a non-space
is found.
// I am checking that iToken < str.length() before I test
while (iToken < str.length()) {
if (!(str.charAt(iToken) == " " )) {
return true; }
else {
return false;}
}
}
}