This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
but I dont know the length of the string array and so when I enter the array at the command prompt then I need to split the coursegrades to course and grade. I have seen the string API but did not know which one to use. Can you please explain clearly.
Joined: Mar 05, 2009
In that case you can use method suggested by Maneesh. Retrieve "grade" as last character of string "cousergrade".
You don't need to split the array at all. You can obtain the individual array elements using the index or an Iterator.
An individual array element in your case is a String.
Again check the String API for a method which will give you the length. The use my earlier suggestion to obtain the last character in the String.
Note: indexes start with 0 and not 1