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.
What is the variable buf for? My teacher told me to put it but I don't know why!
The variable "buf" with the pair of square brackets "" means an array! A set of contiguous memory locations being used to store the similar kinda data value. Here in this case, you use a container to store a set of characters. so you need an array of characters.