am I just missing something obvious?
public class methods
{
public static String translate (String sentence)
{
String temp;
String result[] = new String[10];
int i=0;
Scanner scan = new Scanner (sentence);
temp = scan.next();
while (scan.hasNext())
{
result = temp;
i++;
}
return result[];
}
}
i had to replace my i variable with s because it was italicizing everything
public class methods
{
public static String translate (String sentence)
{
String temp;
String result[] = new String[10];
int s=0;
Scanner scan = new Scanner (sentence);
temp = scan.next();
while (scan.hasNext())
{
result[s] = temp;
s++;
}
return result[];
}
}
Your method is public static String translate (String sentence) but you try to return a String[].
When you post code, please use[code] and [/code] tags as described in [url=http://forum.java.sun.com/help.jspa?sec=formatting ]Formatting tips[/url] on the message entry page. It makes it much easier to read.
will do, thanks for the tip.....I'm still getting the same error...this is my modified code:
import java.util.Scanner;
public class methods
{
public static String[] translate (String sentence)
{
String temp;
String result[] = new String[10];
int i=0;
Scanner scan = new Scanner (sentence);
temp = scan.next();
while (scan.hasNext())
{
result[i] = temp;
i++;
}
return result[];
}
}