| Author |
frame vs. JFrame
|
Abder Rahman Ali
Greenhorn
Joined: Mar 17, 2010
Posts: 1
|
|
Is there a difference between using frame or JFrame as in the following? As, when I ran the program it operated the same.
Thanks.
|
 |
Andy Jung
Ranch Hand
Joined: Feb 07, 2010
Posts: 150
|
|
... in the behavior of your program there shouldn't be a difference as you stated already.
But it would be interesting to see, if byte code differs?
I guess it doesn't, because sun's compiler should recognize that this is a final static field, i.e. a constant.
But anyway, even this doesn't probably relate to your question,
most IDE's would issue a warning if you use latter code
and sun also highly recommends to use the first statement instead.
|
SCJP, SCJD
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 26710
|
|
And welcome to JavaRanch
|
 |
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Posts: 1652
|
|
deleted (misread the question)
|
 |
pete stein
Bartender
Joined: Feb 23, 2007
Posts: 1561
|
|
Since his "frame" is not capitalized, I'm guessing that the OP is not mixing Frame (AWT) with Swing but rather that he has a JFrame variable named "frame" and is asking if calling a static method or referencing a static variable from an object of the class will change his code.
To the OP: as noted above, it likely won't but it will sure confuse folks reading your code since most of us expect static members to be referenced by the class name not by a variable of the class that holds an object of the class. Since much of coding is not writing for a compiler but rather writing for readability, I agree with others who tell you "don't do this".
|
 |
 |
|
|
subject: frame vs. JFrame
|
|
|