This content has been marked as final. Show 4 replies
why do you say x is a variable at private scanner xThe code doesn't actually say it's a variable, but it is. It is a reference of type Scanner. As it isn't initialized in the declaration, its initial value is null.
and then make x an object?It doesn't. it creates a new Scanner instance and then assigns the reference to 'x'.
why do both variable and object?You should now be able to see that the question is meaningless.
In the line in which he has created a refernce to the class Scanner and that reference is in private so that only the owner can use it and the differnce between an object and a variable is nothing in an OOP language until you have declared them as of primitive data typed one's
Something like that ...
If you haven't already taken the Java Tutorial, now would be a good time to dive in... It includes basic like object declaration & instantiation.