| Author |
transient volatile strictfp 's position in SCJP1.4!
|
Mellihoney Michael
Ranch Hand
Joined: Nov 27, 2002
Posts: 124
|
|
|
they are just mentioned as keyword or examed with concrete code???
|
a beginner in java
|
 |
Sridhar Srikanthan
Ranch Hand
Joined: Jan 08, 2003
Posts: 366
|
|
You can expect a question like volatile final int x = 5; is this code valid? or something like interface I1 { transient int x = 5; } is this code valid Hope this helps Sri
|
 |
Mellihoney Michael
Ranch Hand
Joined: Nov 27, 2002
Posts: 124
|
|
can you explain the question above? I don't know that yet thanks. Or can you offer a link which contains some resource on this? Many thanks!
|
 |
Mandar Puranik
Ranch Hand
Joined: Jan 08, 2003
Posts: 35
|
|
Hi Michael, Here is what I have to say : Volatile : Only variables may be volatile. Declaring a variable volatile implies that they can be modified asynchronously. Transient : When a variable is declared as transient, it means that it will not get serialised with the object. In the second example of Sri's post, a transient variable is declared in an interface. This will not compile, and you will get an error, "modifier transient not allowed here". This is because the member variables of an interface are always public, static and final by default. So it wont allow you to declare them as transient. Hope this helps. Regards Mandar
|
To Bug is Human,<br />To Debug Divine... :-))
|
 |
Mellihoney Michael
Ranch Hand
Joined: Nov 27, 2002
Posts: 124
|
|
|
thanks
|
 |
Kathy Sierra
Cowgirl and Author
Ranch Hand
Joined: Oct 10, 2002
Posts: 1572
|
|
Howdy! You do *not* need to know exactly how volatile, transient, and strictfp work. But you *do* need to know where / to what they can be applied. For example, you need to know: * Only non-local variables can be volatile (methods, classes, and local variables cannot be volatile) * Only non-local variables can be transient (methods, classes, and local variables cannot be transient) * Variables cannot be made strictfp, only classes and methods may be strictfp * You cannot make abstract methods (including interface methods) strictfp That's a start : ) My recommendation is to learn enough about what they do so that you'll be able to better remember where it makes sense to use them and where it does not. For example, knowing that marking a variable transient means, "skip this variable when saving the object's state during serialization", makes it easier to remember that 'transient' is about instance variables and not methods or classes. And if you remember that strictfp is about 'behavior' rather than state, it makes more sense that strictfp can be applied to methods but not variables. (Then you still have to remember that strictfp can be applied to classes, but that's just a way of saying, "make every method in the class strictfp") cheers and good luck, Kathy
|
 |
Mellihoney Michael
Ranch Hand
Joined: Nov 27, 2002
Posts: 124
|
|
thanks to all guys
|
 |
 |
|
|
subject: transient volatile strictfp 's position in SCJP1.4!
|
|
|