How does a Java class get input?
<p>I'm a beginner to programming (and Java) and could use some help with the basic concepts.
This is a sample from my reading about constructors, set and get statements.</p>

<pre><code>1   // Fig. 3.10: GradeBook.java
2   // GradeBook class with a constructor to initialize the course name.
3
4     public class GradeBook
5     {
6         private String courseName; // course name for this GradeBook
7
8         // constructor initializes courseName with String supplied as argument
9         public GradeBook( String name )
10        {
11              courseName = name; // initializes courseName
12        }
13
14        // method to set the course name
15        public void setCourseName( String name )
16        {  
17             courseName = name; // store the course name
18        } // end method setCourseName
19
20        // method to retrieve the course name
21        public String getCourseName()
22        {
23             return courseName;
24        } // end method getCourseName
25   
26        // display a welcome message to the GradeBook user
27        public void displayMessage()
28        {
29            // this statement calls getCourseName to get the
30            // name of the course this GradeBook represents
31            System.out.printf( "Welcome to the grade book for\n%s!\n",
32              getCourseName() );
33        }    // end method displayMessage
34
35    } // end class GradeBook
</code></pre>

<p>I am having a little difficulty understanding the steps going between sets and gets.  My book didn't really explain anything, but how do they prompt for the user to input data? Is the prompt for input part of one of these by default?  All I understand is that the method setCourseName( String name ) means the course name has to be a string.  But I don't understand the instance variable of courseName = name.  or the function of the getCourseName method.  Can you help me to understand this example?</p>
