This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I've written this code to create an array containing all the letters in a string. However, originally in my method, I used charAt, but I kept getting an error message. So, I tried substring and it worked fine. Can anyone tell me why charAt wouldn't work in this case? Thanks.
Well if you were trying to do ca[ i ] = s.charAt( i ), you would get an error because you're trying to put a char type into a String array, they are incompatible. You would need to change ca to an array of characters, not an array of Strings. By the way, in case you didn't know, there is a method called toCharArray() in class String, that does exactly what you are looking for. Jason