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

Char or String ?

+7 votes
If String name = "csc" and name.substring(1,2)= sc is the result(sc) considered as a string or a char
asked Oct 10, 2016 in CSC 211 (F16) by Samih Sghier (100 points)

8 Answers

+5 votes
.substring(x,y) is actually y-exclusive. So the result in this case would be "s" but would still be considered a string.
answered Oct 10, 2016 by Brandon Thompson (100 points)
+4 votes
Definitely considered a string
answered Oct 10, 2016 by Lucas Simon (100 points)
+4 votes
That my friend is still a string, because it is only subdividing the string into a smaller piece of itself.
answered Oct 11, 2016 by Hunter Bader (100 points)
+2 votes
Pretty sure it is still considered a string because you are just finding that range of characters within a string.

Same thing as if you were using the string.charAt(x); method it would be finding a character but that character is stored as a string if I remember correctly.
answered Oct 13, 2016 by Dylan Hart (100 points)
+1 vote
I believe it is considered a String, however I could be wrong
answered Oct 10, 2016 by Trenton Jackson (100 points)
+1 vote
you would still be left with "sc" which is a string
answered Oct 10, 2016 by Paige Oucheriah (100 points)
.substring(x,y) is actually y-exclusive. This means that it will go up to but not include the character at index y. So in this case, you would be left with "s" which would still be a String object in this case.
+1 vote
Pretty sure it is still considered a string because you are just finding that range of characters within a string.
answered Oct 13, 2016 by Dylan Hart (100 points)
+1 vote
It's a String.
answered Oct 13, 2016 by Trung Le (Jayden) (100 points)
...