Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

in the winter 2015-16 edition mid term can you help me understand what it means by: result (s+d).charAt(n); Thank you!

+2 votes
asked Oct 10 in CSC 211 (F17) by Thomas Ayele (2,935 points)

1 Answer

+1 vote

I think you mean question A3 (Duckie), which has the method:

public static char quack(String s, int n, double d) {
    return (s+d).charAt(n);
}

This method takes a string, a double, and an int as parameters. It concatenates the double onto the end of the string (that's the s+d part), finds the character at index n in that string (that's the .charAt(n) part), and returns it.

answered Oct 10 by Vecna (3,831 points)
So does that mean that it only returns the character at n? or the string (s+d) until character n?
It returns the character at index n from the string (s+d). It only returns a single character (which is also shown by the return type char) - the one at n.
...