[exit Q&A]
Questions and AnswersHow about looking at the examples we have in the lecture notes and find there how fields and methods are defined?
Each data type offers a distinguished set of values. For instance, the ‘int’ type offers values like 10, -55, and 12345. Similarly, the ‘long’ data type offers values like 52L and -987L.
In the case of non-primitive data types, the values are said to be objects. To get a value, that is an object, of a class type Foo one needs to use instructions of the form ‘new Foo(...)’.
A variable is a named storage place where values can be recorded. For instance, ‘int i’ introduces a variable named ‘i’ where integer values can be stored. On the other hand, the instruction ‘Foo x’ introduces a variable named ‘x’ where objects of type Foo can be stored.
The storing of values is achieved with assignment instructions. For instance, ‘i = 68’ and ‘x = new Foo(...)’.
Yes, please.
can I put more?
No.