Alright so I just began taking a class learning about entry level java programming, and so far decently good but I have run into a problem writing a homework program. In my head this program seems to work. However in eclipse it keeps telling that i can't convert this char to a string. I have to follow these instructions:
copySubsequence(): this method accepts a String s and two ints a and b as parameters. The
method returns a new String that contains all the characters to the right of position a and left of
position b in s, inclusively. For example, if s = abcdef, a = 0, b = 3, then the method will return
abcd.
Note: that the characters in a String are numbered starting at 0. If a String has n characters, the
last character is at position n-1. If you try to access a String character at position 5, say, your
program will crash. Similarly, trying to access a String character at position n will also cause the
program to crash.
The copySubsequence() method addresses \bad" values of a and b as follows:
{ If a (or b) is less than 0, its value is changed to 0.
{ If a (or b) is greater than or equal to the length n of s, its value is changed to n - 1.
{ If a is greater than b the method returns an empty String (since there is nothing that is both
to the right of a and to the left of b).
{ If s is empty, the method returns s.
Here's my attempt at the program
public class Mutations {
public static String copySubsequence(String s, int a, int b) {
if (a < 0) a = 0;
if (b < 0) b = 0;
if (a >= s.length()) a = s.length() - 1;
if (b >= s.length()) b = s.length() - 1;
if (a > b) return "";
if (s == "" ) return s;
while (a <= b) {
return s.charAt(a);
a++;
}
}
Thanks!

